View Full Version : Path File Java
soccersquirt82
Oct 9, 2008, 09:21 AM
I am trying to write the file path for a file. I've tried many different ways such as using slashes, colons, extensions, spaces, etc., but I can't get it to work. The path on my Finder shows
"Macintosh HD/Users/crawfordcrenshaw/Documents/starburst". The extension of the "starburst" document is "pages". How do I write this path in my code?
toddburch
Oct 9, 2008, 10:35 AM
"/Users/crawfordcrenshaw/Documents/starburst.pages"
soccersquirt82
Oct 9, 2008, 10:39 AM
AHHHH!! Thank you! It didn't work in Pages, but I made it a rtf file and it worked! Except. . . When I debug the program, the "word" is a continuous string that looks like this: "\rtf1\ansi\ansicpg1252\cocoart". It's supposed to only have words such as "strawberry," "lemon," "cherry," and "orange." When I did this on Windows, the exact same program worked perfectly, which leads me to believe the problem has to do with the app I'm using, TextEdit. Is there a different app I should use?
skinnybeans
Oct 9, 2008, 11:18 PM
AHHHH!! Thank you! It didn't work in Pages, but I made it a rtf file and it worked! Except. . . When I debug the program, the "word" is a continuous string that looks like this: "\rtf1\ansi\ansicpg1252\cocoart". It's supposed to only have words such as "strawberry," "lemon," "cherry," and "orange." When I did this on Windows, the exact same program worked perfectly, which leads me to believe the problem has to do with the app I'm using, TextEdit. Is there a different app I should use?
Textedit is fine to use, but you need to make sure you save the file as plain text, not rtf. rtf contains lots of extra markup.
Think of it like html. If you open a html file in a brower, all you see is the final result of the mark up (because it knows how to read the tags), if you open it in a text editor you see all the tags. If you open an rtf document as plain text, you will see extra stuff in there.
I use TextWrangler for editing text files, it is free and a bit more developer friendly that using textedit.
SC68Cal
Oct 10, 2008, 04:20 AM
You should use the java PathSeperator to ensure cross platform compatibility.
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#separatorChar
toddburch
Oct 10, 2008, 05:55 AM
You should use the java PathSeperator to ensure cross platform compatibility.
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#separatorChar
Windows is changing to a root directory scheme and dropping the drive letter? :eek:
skinnybeans
Oct 10, 2008, 05:17 PM
Windows is changing to a root directory scheme and dropping the drive letter? :eek:
hehe yep this is a good point. To get around this problem you either need to use relative paths or set up a .properties file for your application that contains the absolute path to any directories that you need to access. Had this problem recently at work actually when i was trying to get our java app running on os x, required a bit of stuffing around actually but got there in the end!
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.