Eclipse PrintWriter no file created [duplicate]

拜拜、爱过 提交于 2019-12-13 07:32:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!