IOException cannot be resolved to a type

Horrison2 2009-07-22 02:18:53
package com.org;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class IoTest {

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

int i;
String s="";
try{

FileInputStream in=new FileInputStream("c:\\demo.txt");
FileOutputStream out=new FileOutputStream("c:\\demo1.txt");
try
{while((i=in.read())!=-1)
{
s=s+(char)i;
out.write(i);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
}


哪儿错了?
...全文
441 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Horrison2 2009-07-22
  • 打赏
  • 举报
回复
import java.io.IOException; 少了个这个包
weifangan 2009-07-22
  • 打赏
  • 举报
回复
先捕获FileNotFoundException然后才是IOException
alpha_423 2009-07-22
  • 打赏
  • 举报
回复
没错可以运行,输入输出流用完后记得关闭

62,614

社区成员

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

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