2.2 FileReader的用法 (视频下载) (全部书籍)
FileReader是Reader的继承类,从字面上就可看出,它的主要功能就是能从磁盘上读入文件。read方法会一个一个字符的从磁盘往回读数据。
例:2.2.1
import java.io.*;
public class TestMark_to_win {
public static void main(String args[]) throws Exception {
/*public int read()
throws IOException
Reads a single character.
Overrides:
read in class Reader
Returns:
The character read, or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs */
int ii;
FileReader in = new FileReader("c:/1.txt");
while ((ii = in.read()) != -1) {
System.out.println(ii);
}
in.close();
FileReader in1 = new FileReader("c:/1.txt");
while ((ii = in1.read()) != -1) {
详情请见:http://www.mark-to-win.com/index.html?content=JavaBeginner/javaUrl.html&chapter=JavaBeginner/JavaBeginner8_web.html#UsageOfFileReader