Eclipse starts project with workdir = project dir by default, so src is right under workdir. Use relative path
File file = new File("src/fileName");
Pregunta
I am making a (tile)level editor using java and eclipse as IDE. I am using getResourceAsStream to load tilemap. And this code to write map back.
URL resourceUrl = getClass().getResource(FILENAME);
File file = new File(resourceUrl.toURI());
OutputStream output = new FileOutputStream(file);
It works fine, but the problem, that i have two direcotries bin/ and src/. Directory bin/ will be generated by eclipse. So i want edit files in src dir. Unfortunately getResource() works with bin/ direcoty. Moreover, if i rebuild a project, all changes on map will be deleted. So i just want to edit tilemaps in src/ folder. How can i achieve that?
I would like to avoid hardcoding some absoulte paths.
Solución
Eclipse starts project with workdir = project dir by default, so src is right under workdir. Use relative path
File file = new File("src/fileName");