I'm trying to read a file in java:
Public class Test{
public static void main (String [] args) throws IOException {
BufferedReader f = new BufferedReader(new FileReader("test.in"));
//...
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("test.out")));
//...
}
}
1) Where should the location of "test.in" be? (src? bin? ???)
2) Where will "test.out" be located?
A relative path'ed file is looked for in the directory specified by System.getProperty("user.dir")
The answer is the working folder, which means the folder in which you executed the "java ..." command. This is the project folder in eclipse projects for instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With