没有捕获异常
用try ... catch ...
或者用个throw ,一般java书上都有建议用eclipse把,错误提示的很明显呢
用try ... catch ...
或者用个throw ,一般java书上都有建议用eclipse把,错误提示的很明显呢
解决方案 »
- 字节流无法读取到二进制数据的-1标志
- 怎么实现点击按钮时打开邮箱?
- 编程思想中一不明白的例子
- String变量是不是不能更改其内部的具体部分,而可以整体被赋值、修改?
- 用javascript验证数据类型??
- 急求:Bidr对象(如何通过通过scoket发送给服务端)是啥东西啊。
- 为什么下载的邮件附件打开时是乱码,直接打开也是一样的?
- 怎样将标准的C++代码转换成JAVA代码??
- How to get the error message when execute "Runtime.getRuntime().exec('javac demo.java')"?
- ★各位大虾,这样一样程序能实现吗?
- 请高手帮忙编写这个简单程序,谢谢!
- 2008奥运趣味题
import java.io.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class writeFile
{
public writeFile()
{
}
public static void main(String[] args)
{
String aa = "d:\\aaa.txt";
File my = new File(aa);
PrintWriter pw = null;
try
{
pw = new PrintWriter(new FileOutputStream(my));
}
catch (FileNotFoundException ex)
{ }
pw.println("我是中国人");
pw.close();
}}
new PrintWriter
语句必须用try,catch或者throw?
throws FileNotFoundException
Throws:
FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
SecurityException - if a security manager exists and its checkWrite method denies write access to the file.