Take the 2-minute tour ×

I am working on a java project and I was wondering if it is possible to write a code that can create a txt file directly into the bin folder (for example the bin folder for eclipse, where I can use getClass() to access the txt files) so that the user will not be able to see the created txt files when using the program.

share|improve this question
What do you mean user will not be able to see it? He will always be able to do this as long as he has proper authorizations to access directories and files in the file system. –  Jagger Nov 2 '12 at 18:36
add comment

1 Answer

up vote 5 down vote accepted

You can surely do this. But think again. User does not run program from Eclipse. User typically runs program packed in jar, so all class files are not in filesystem but into jar. Moreover the user even probably does not have rights to write into file system except special folders.

Bottom line: you you want to create application that stores some run-time data in file system you should either user user home or temporary directory or use java.util.prefs.Preferences that provide platform independent way to save and retrieve data using file system in unix and registry in windows.

If you choose to create file yourself you can retrieve use home and temporary directory using system properties user.home and java.io.tmpdir.

share|improve this answer
Can I create a temporary txt files within the generated jar at run-time or I have to use the java.io.tmpdir or any other directory? –  ChimstarTech Nov 3 '12 at 14:43
add comment

Your Answer


