Java: how do I read from files in XCode?

ElDiabloConCaca

U.S.D.A. Prime
I'm a computer science major in college right now, and am trying my best to program everything using XCode on my Macintosh rather than use a PC with JBuilder. So far, so good -- only one thing holding me back from a project or two...

I have a project that reads data from files and outputs certain things. No biggie. In JBuilder, all I need to do is place the data files in the same directory as the project and JBuilder finds them just fine. However, in XCode, I cannot figure out where to place these files. I've even tried making the filenames into absolute paths in the Java code itself, like instead of "dataA.dat" I'll put "/users/(myusername)/Desktop/EasyReader/dataA.dat" but that's a no-go.

Do I need to add these files to the project somehow? Where in the heck do I put these files so my project can access them?!
 
Good to hear. My computer science class revolves around Java as well, so I will have to figure out how to get Xcode to work for me the way I want it to.
 
XCode is easy as pie to work with in Java. One little quirk I found is that you must name your project the same name as the main class, whereas on a PC and JBuilder, you just need to remember to declare what package the files belong to with a "package (packagename);"

I'm sure this isn't a requirement for XCode, but I haven't figured out how to get it to work unless I do that. When I do name the project the same name as the main class, everything runs smooth as glass.
 
I'm sure it's easy, I just haven't given myself enough time to figure it out yet. ;) I have no doubt that I'll be completing most if not all of my assignments in Xcode rather than the Java SDK on Windows.
 
I normally use Netbeans for Java development. Eclipse is good too, and both of them are available on all platforms. That way, I get to move between machines without any problems.
 
Back
Top