import java.io.*;
class FileReaderTest
{
public static void main (String[] args)throws IOException
{
FileReader fr = new FileReader
("FileWriterDemo3.java");
char [] buf = new char[1024];
int num = 0;
while ((num=fr.read(buf))!=-1)
{
System.out.println(new String(buf,0,num));
}
作者: 刘基军 时间: 2012-2-9 21:00
你检查一下第10行程序,是否有非法字符。建议手动重输入一遍。作者: 梅雄新 时间: 2012-2-9 21:03
import java.io.*;
class FileReaderTest
{
public static void main (String[] args)throws IOException
{
FileReader fr = new FileReader
("FileWriterDemo3.java");
char [] buf = new char[1024];
int num = 0;
while ((num=fr.read(buf))!=-1){ //楼主此处显示有非法字符
System.out.println(new String(buf,0,num));
}
fr.close();
}
}//少了大括号作者: 彭沛东 时间: 2012-2-9 21:35
貌似可能是楼主第十行那 FileReader fr = new FileReader ("FileWriterDemo3.java"); 这个用空行隔开了。
ps:
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("C:\\Users\\admin\\Desktop\\config.txt");
char[] buf = new char[1024];
int num = 0;
while ((num = fr.read(buf)) != -1) {
System.out.println(new String(buf, 0, num));
}
fr.close();
}作者: Joyuang 时间: 2012-2-9 22:35
import java.io.*;
class FileReaderTest
{
public static void main (String[] args)throws IOException
{
FileReader fr = new FileReader
("FileWriterDemo3.java");
char [] buf = new char[1024];
int num = 0;
while ((num=fr.read(buf))!=-1)
{
System.out.println(new String(buf,0,num));
}