• BufferedInputStream


      BufferedInputStream:缓冲字节输入流,是一个高级流(处理流),与其他低级流配合使用。

      查看源码可见 BufferedInputStream 没有无参构造方法,它必须传入一个IputStream 一般是FileInputStream。

      /**
      * 创建一个 BufferedInputStream 并保存其参数,即输入流 in,以便将来使用。创建一个内部缓冲区数组并将其存储在
       *buf 中,该buf的大小默认为8192。

       */
      public BufferedInputStream(InputStream in) {
       this(in, DEFAULT_BUFFER_SIZE);
      }
      /**
       * 创建具有指定缓冲区大小的 BufferedInputStream 并保存其参数,即输入流 in,以便将来使用。创建一个长度为
    *size 的内部缓冲区数组并将其存储在 buf 中

       */
      public BufferedInputStream(InputStream in, int size) {
       super(in);
       if (size <= 0) {
       throw new IllegalArgumentException("Buffer size <= 0");
       }
       buf = new byte[size];
      }

      常用方法
      //从该输入流中读取一个字节
      public synchronized int read() throws IOException {
       if (pos >= count) {
       fill();
       if (pos >= count)
       return -1;
       }
      return getBufIfOpen()[pos++] & 0xff;
      }
      //从此字节输入流中给定偏移量处开始将各字节读取到指定的 byte 数组中。 
      public int read1(byte[] b,int off,int len) throws IOException{xxxxx}
  • 相关阅读:
    Linux Shell编程 sort、wc命令
    Linux Shell编程 sed命令
    Linux Shell编程 awk命令
    Linux Shell编程 cut、print命令
    Linux Shell基础 环境变量配置文件
    Linux Shell基础 read命令
    Linux Shell基础 位置参数变量、预定义变量
    MS DOS 命令大全
    sublime 快捷键
    滚动到页面底部继续加载页面其他内容
  • 原文地址:https://www.cnblogs.com/z0909y/p/9242902.html
Copyright © 2020-2023  润新知