package cm;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class test20180418Bufferinputstream {
public static void main(String[] args) {
// bufferinputstream类的主要方法
// BufferedInputStream(InputStream in)
// BufferedInputStream(InputStream in, int size)
// synchronized int available()
// void close()
// synchronized void mark(int readlimit)
// boolean markSupported()
// synchronized int read()
// synchronized int read(byte[] buffer, int offset, int byteCount)
// synchronized void reset()
// synchronized long skip(long byteCount)
File f = new File("D:\\a.txt");
try {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
// for (int i = 0; i < 6; i++) {
// System.out.println(in.available());// in.available返回输入源中还可读取的字节数。
// if (in.available() > 0) {
// int inn=in.read();
// System.out.printf("%d:0x%s\n",inn,Integer.toHexString(inn));//inn为0-255之间的字节值。如果到达文件尾部,则read返回为-1
// }
// }
// System.out.println(in.markSupported());//判断bufferdinputstream是否支持mark操作,返回值为true,支持
// in.mark(2);// 设置一个索引标志,作为输入源重置后的读取起点。
// for (int i = 0; i < 6; i++) {
// int inn = in.read();
// if (i > 1) {
// in.reset();// 将输入源读取的索引重置为mark标记处的索引。
// }
// System.out.println(inn);
// }
// byte[]by=new byte[11];
// in.read(by);
// System.out.println(new String(by));//将读取的数据装入字节数组。
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
BufferedInputStream
最新推荐文章于 2021-12-30 19:21:15 发布