I want to create a new .txt file inside my project folder and I want to give it this path:
Contents/FrameClasses/Data/Datafiles/MYFILE.txt
What I use to make the folder is this:
File MYFILE = new File("Contents/FrameClasses/Data/Datafiles/MYFILE.txt");
MYFILE.getParentFile().mkdir();
try{
if(MYFILE.createNewFile()){
//do stuff here
}
}catch (Exception e){
//do stuff with the exception...
}
Whenever I do this I get an error saying:
java.io.IOException: No such file or directory
The error is fixed if I add src/ to the beginning of my path and make it like this:
src/Contents/FrameClasses/Data/Datafiles/MYFILE.txt
But the src/ is not part of my project as everything is contained inside the Contents folder I've made. When I build the .jar file it gives the same error if I run it once I add the src/ to the path.
What would be the proper way to create this file ?
PS: I've tried using a shorter path like this one as well: Datafiles/MYFILE.txt without success. Also, the class I use to make the file is contained inside the folder Data alongside with Datafiles as shown in the original path.