日期:2014-05-20 浏览次数:20874 次
package filereader;
import java.io.FileReader;
import java.io.IOException;
import static java.lang.System.out;
class FileReaderDemo2{
public static void main(String[] args)throws IOException{
FileReader fr = new FileReader("c:\\test.txt");//文件内容a
char[] buf = new char[3];//定义数组长度为3
int num=fr.read(buf);
out.println("num="+num+"..."+new String(buf));
num=fr.read(buf);
out.println("num="+num+"..."+new String(buf));
num=fr.read(buf);
out.println("num="+num+"..."+new String(buf));
out.println("over");
}
}