Quote:
Originally Posted by GeeTwo
Code:
.
.
Map<String, String> env = System.getenv();
.
.
f = new File(env.get("HOME") + "/Output.txt");
.
.
|
Another option is simply defining a non-absolute path, which would make the file relative to the working directory (where the jar file is located).
Code:
File file = new File("Output.txt");
Other than that, referring to solving "File or directory not found," you also have to create the directory that the desired file resides in, in addition to the actual file.
Code:
File file = new File("new_directory/Output.txt");
file.mkdirs();
file.createNewFile();
This would ensure that the directory "new_directory" is created before "Output.txt" is created.