BufferedInputStream

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();
		}

	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值