请问PrintWrite这行会报错呢?

yyxgs 2016-08-05 05:24:20
package One;

import java.util.*;
import java.lang.*;
import javax.print.DocFlavor.STRING;
import java.io.*;

public class One {

public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner input = new Scanner(System.in);

File file = new File("c:\\下载\\1.txt");
if (file.exists()) {

System.out.println("File already exists");
System.exit(0);
}

PrintWrite ouput = new PrintWrite("c:\\下载\\1.txt");


}
}


...全文
232 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyxgs 2016-08-05
  • 打赏
  • 举报
回复
引用 4 楼 wlwlwlwl015 的回复:
加try..catch捕获异常。。

  try {
			PrintWriter ouput = new PrintWriter("c:\\下载\\1.txt");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
谢谢!
yyxgs 2016-08-05
  • 打赏
  • 举报
回复
引用 2 楼 soton_dolphin 的回复:
PrintWriter
谢谢
小灯光环 2016-08-05
  • 打赏
  • 举报
回复
加try..catch捕获异常。。

  try {
			PrintWriter ouput = new PrintWriter("c:\\下载\\1.txt");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
yyxgs 2016-08-05
  • 打赏
  • 举报
回复
引用 2 楼 soton_dolphin 的回复:
PrintWriter


哦哦,为什么改了怎么还是错呢?
soton_dolphin 2016-08-05
  • 打赏
  • 举报
回复
PrintWriter
yyxgs 2016-08-05
  • 打赏
  • 举报
回复

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧