Eclipse PrintWriter没有创建文件 [英] Eclipse PrintWriter no file created

查看:220
本文介绍了Eclipse PrintWriter没有创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK现在我有这个

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();
}

}

为什么eclipse不创建文件一旦运行程序?

Why doesn't eclipse create a file once I run the program?

推荐答案

查看您的工作目录。默认情况下,它可能是您的项目的根文件夹。您还可以通过提供完整路径来验证文件是否被写入:

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");

这篇关于Eclipse PrintWriter没有创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆