Mac referencing a file in java

greatm31

macrumors member
Original poster
Oct 19, 2001
69
27
Okay so I wrote a program over a year ago on a PC in java that I want to use on my nice new Powerbook. I've got it all loaded into XCode, but there's just one teeny little line that won't work. I'm trying to load a txt file filled with a bunch of numbers into a File object with this line:

File periods = new File("...");

Where, at least on Windows, the "..." was the file path to the text file "periods.txt." I don't know how to describe the file path on a mac. The file is in the same folder as all the .java files. What should I do? Thanks.
 

VegetaPunk

macrumors 6502
Dec 30, 2002
322
0
AZ
Im not 100% positive but you might want to try something like this

/Volumes/Macintosh HD/Periods Folder/Periods.txt

Ill look into it more when I get home to my comp.
 

jcgerm

macrumors member
May 28, 2003
91
0
VegetaPunk said:
Im not 100% positive but you might want to try something like this

/Volumes/Macintosh HD/Periods Folder/Periods.txt

Ill look into it more when I get home to my comp.
Sort of...You should use File.separator instead of the "/" if you want it to be cross platform. Check out the documentation on the File class too.