referencing a file in java

Discussion in 'Mac Programming' started by greatm31, Jun 21, 2005.

  1. greatm31 macrumors member

    greatm31

    Joined:
    Oct 19, 2001
    #1
    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.
     
  2. VegetaPunk macrumors 6502

    Joined:
    Dec 30, 2002
    Location:
    AZ
    #2
    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.
     
  3. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #3
    Is it in the same dir as your .class files? Or the CWD when you invoke the JVM?
     
  4. jcgerm macrumors member

    Joined:
    May 28, 2003
    #4
    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.
     

Share This Page