file access question

Discussion in 'Mac Programming' started by javaBeans, Jan 19, 2006.

  1. macrumors newbie

    Joined:
    Jan 19, 2006
    Messages:
    3
    #1
    hi all, im new to the mac platform, new to mac programming and new to xcode.

    For a assignment in school i need to do some basic file access operations in java. the problem is how do i do that in xcode? i have a input file in the same directory as the .java file but everytime i try to run it give me a IOException error. o btw the input file is a .rtf file could that be the problem? what do i need to do in order to read this file in my program?
     
  2. Moderator emeritus

    Joined:
    Jun 25, 2002
    Messages:
    13,951
    Location:
    Gone but not forgotten.
    #2
    You'll have to learn how to read the format. It's not easy to do, but you might find a Java library if you search on Rich Text Format.

    You might start with learning to read a plain text file to refine your techniques and work up to reading more sophisticated file formats.
     
  3. macrumors newbie

    Joined:
    Jan 19, 2006
    Messages:
    3
    #3
    well, actually even when i try to read in a txt file it still gives me a IOException and exits with "status 1"??? what is that supposed to mean...
    there shouldn't be ne problems with the code cuz i've done it many times before on the PC. does anybody know whats going on? im sure i put the file in the right location, its in the same directory as the java file...
     
  4. Moderator

    robbieduncan

    Staff Member

    Joined:
    Jul 24, 2002
    Messages:
    24,480
    Location:
    London
    #4
    What path are you giving to the file? If possible give it an absolute path. If you are just saying "file.txt" it will probably not work as that won't be in your current path. Use something like "/Users/javaBeans/files/files.txt".
     
  5. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Messages:
    5,478
    Location:
    Fox Lake, IL
    #5
    When you ask for help, posting code (applicable snippets are fine) AND associated stack traces can really help us help you...Also, when you do this, learn to use the code tags...
     
  6. macrumors newbie

    Joined:
    Jan 19, 2006
    Messages:
    3
    #6
    ok thx for all the replies, i got it figured out now!
     

Share This Page