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.
I am working on a java project and I was wondering if it is
Share
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.Preferencesthat 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.homeandjava.io.tmpdir.