TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
package com.zhangjie.stream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TestBufferStream {
public static void main(String[] args) throws IOException {
try {
FileInputStream fis = new FileInputStream("E:\\java\\IO\\input.dat");
BufferedInputStream bis = new BufferedInputStream(fis);
int c = 0;
System.out.println((char)bis.read());
System.out.println("------------");
System.out.println((char)bis.read());
System.out.println("------------");
bis.mark(100);
for(int i = 0;i <=10&&(c=bis.read()) != -1;i++){
System.out.println((char)c+" ");
}
System.out.println("------------");
bis.reset();
for(int i = 0;i <=10&&(c=bis.read()) != -1;i++){
System.out.println((char)c+" ");
}
bis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
} |
|