Path File Java

Discussion in 'Mac Programming' started by soccersquirt82, Oct 9, 2008.

  1. soccersquirt82 macrumors 6502

    Joined:
    Mar 11, 2008
    #1
    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?
     
  2. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #2
    "/Users/crawfordcrenshaw/Documents/starburst.pages"
     
  3. soccersquirt82 thread starter macrumors 6502

    Joined:
    Mar 11, 2008
    #3
    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?
     
  4. skinnybeans macrumors newbie

    Joined:
    Dec 6, 2007
    #4
    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.
     
  5. SC68Cal macrumors 68000

    Joined:
    Feb 23, 2006
  6. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #6
  7. skinnybeans macrumors newbie

    Joined:
    Dec 6, 2007
    #7
    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!
     

Share This Page