📜  Java.io.BufferedInputStream类

📅  最后修改于: 2020-11-15 02:37:59             🧑  作者: Mango


介绍

Java.io.BufferedInputStream类将功能添加到另一个输入流,该功能可以缓冲输入并支持mark和reset方法。以下是有关BufferedInputStream的要点-

  • 创建BufferedInputStream时,将创建一个内部缓冲区数组。

  • 当读取或跳过流中的字节时,根据需要从包含的输入流中重新填充内部缓冲区,一次填充许多字节。

类声明

以下是Java.io.BufferedInputStream类的声明-

public class BufferedInputStream
   extends FilterInputStream

领域

以下是Java.io.BufferedInputStream类的字段-

  • protected byte [] buf-这是内部缓冲区数组,用于存储数据。

  • protected int count-这是比缓冲区中最后一个有效字节的索引大一个的索引。

  • protected int marklimit-这是在调用mark方法之后,随后对reset方法的调用失败之前允许的最大读。

  • protected int markpos-这是最后一个mark方法调用时pos字段的值。

  • protected int pos-这是缓冲区中的当前位置。

  • −中的protected InputStream这是要过滤的输入流。

类的构造函数

Sr.No. Constructor & Description
1

BufferedInputStream(InputStream in)

This creates a BufferedInputStream and saves its argument, the input stream in, for later use.

2

BufferedInputStream(InputStream in, int size)

This creates a BufferedInputStream with the specified buffer size, and saves its argument, the input stream in, for later use.

类方法

Sr.No. Method & Description
1 int available()

This method returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.

2 void close()

This method closes this input stream and releases any system resources associated with the stream.

3 void mark(int readlimit)

This method see the general contract of the mark method of InputStream.

4 boolean markSupported()

This method tests if this input stream supports the mark and reset methods.

5 int read()

This method reads the next byte of data from the input stream.

6 int read(byte[] b, int off, int len)

This method reads bytes from this byte-input stream into the specified byte array, starting at the given offset.

7 void reset()

This method repositions this stream to the position at the time the mark method was last called on this input stream.

8 long skip(long n)

This method skips over and discards n bytes of data from this input stream.

方法继承

此类从以下类继承方法-

  • Java.io.FilterInputStream
  • Java对象