问题
OK so now I have this
import java.io.*;
public class driver {
public static void main(String[] args) {
PrintWriter out = null;
try {
out = new PrintWriter("output.txt");
}
catch (FileNotFoundException e) {
System.out.print("file not found");
e.printStackTrace();
}
out.print("hello");
out.close();
}
}
Why doesn't eclipse create a file once I run the program?
回答1:
Look in your working directory. It may be the root folder of your project by default. You can also verify that the file is written by supplying a full path:
out = new PrintWriter("C:\\Temp\\output.txt");
来源:https://stackoverflow.com/questions/22547365/eclipse-printwriter-no-file-created