I know how to create file in Java with a specific path.
I want to create file in the source folder of the project without specifing the drive because it can change from PC to PC.
I tried to use:
File targetFile = new File("/src/SavedGames/uploadedFile.xml");
targetFile.createNewFile();
with dot before the 'src':
File targetFile = new File("./src/SavedGames/uploadedFile.xml");
targetFile.createNewFile();
with \\
:
File targetFile = new File("\\src\\SavedGames\\uploadedFile.xml");
targetFile.createNewFile();
It doesn't work, it throws exception.
This one works but creates it on my Apache server folder:
File targetFile = new File("uploadedFile.xml");
targetFile.createNewFile();
This is the hierarchy:
The code runs on the LoadGameServlet.java