PDA

View Full Version : file access question




javaBeans
Jan 19, 2006, 09:59 PM
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?



bousozoku
Jan 19, 2006, 11:25 PM
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.

javaBeans
Jan 20, 2006, 09:29 AM
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...

robbieduncan
Jan 20, 2006, 09:36 AM
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...

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".

jeremy.king
Jan 20, 2006, 12:08 PM
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...

javaBeans
Jan 20, 2006, 02:36 PM
ok thx for all the replies, i got it figured out now!