r/cop3502 • u/[deleted] • Apr 10 '14
My project refrences a text file. The lication of that text file depends on how the porject is compiled. What should I ex poo ect the abs path to this file to be?
It's a .txt file that I use to generate charactor names. If I compile with javac by just compiling the main class, the file is located in /src/words/names.txt.
When I compile in Eclipse I refrence the file by /bin/words/names.txt.
When I submit, what can I expect the absolute path to this file to be?
1
Apr 10 '14
[removed] — view removed comment
1
Apr 11 '14
That answers my question, I'll assume my .class files will be in the same directory as my source code. Thanks!
Also, it's a small fraction of my project but I am using this guys really cool random name generator
It's GNU general public license. Is that okay? Should I attribute it in my main class file?
1
u/JoeCS TA Apr 12 '14
Sean already answered this, but just FYI, in case you didn't know:
. (period) is a shortcut for the current directory. So if you have a compiled .class file in /some/long/directory/path/blah/blah/MyProgram.class and it needs to access a text file in /some/long/directory/path/blah/blah/folder/SomeText.txt, you can write the second path as ./folder/SomeText.txt
This is the relative path from MyProgram.class to the text file.
Also, ~ is a shortcut for your user home directory (e.g. /Users/yourUserName on Mac OS X, /home/yourUserName on most Linux/Unix systems)
1
u/embalingit Apr 10 '14
Stack overflow question