[求助]编译出错,WHY?
import java.io.*;
public class lx_1
{
public static void main(String [] args)
{
char data[] = new char[1024];
FileReader fr = new FileReader ("C:\\tommy.txt");//路径没错。
int num = fr.read(data);
String st = new String (data,0,num);
System.out.println("该文本有: "+num+" 个字符!");
System.out.println(st);
fr.close();
}
}
图片是出错说明
[此贴子已经被作者于2006-10-25 22:57:09编辑过]
----------------解决方案--------------------------------------------------------
你没有抛出异常!上面已经写的很清楚了!应该抛出 throws FileNotFoundException
public int read(char[] cbuf,
int offset,
int length)
throws IOException 这是read的异常!
----------------解决方案--------------------------------------------------------
正解
----------------解决方案--------------------------------------------------------
建议楼主好好把英文学一下,因为编译器已经用英文告诉你错在哪里了
----------------解决方案--------------------------------------------------------
谢谢。。以后学英文
----------------解决方案--------------------------------------------------------