类 FastByteArrayOutputStream

java.lang.Object
java.io.OutputStream
org.tio.utils.hutool.FastByteArrayOutputStream
所有已实现的接口:
Closeable, Flushable, AutoCloseable

public class FastByteArrayOutputStream extends OutputStream
基于快速缓冲FastByteBuffer的OutputStream,随着数据的增长自动扩充缓冲区

可以通过toByteArray()toString()来获取数据

close()方法无任何效果,当流被关闭后不会抛出IOException

这种设计避免重新分配内存块而是分配新增的缓冲区,缓冲区不会被GC,数据也不会被拷贝到其他缓冲区。

作者:
biezhi
  • 构造器详细资料

    • FastByteArrayOutputStream

      public FastByteArrayOutputStream()
    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(int size)
  • 方法详细资料

    • write

      public void write(byte[] b, int off, int len)
      覆盖:
      write 在类中 OutputStream
    • write

      public void write(int b)
      指定者:
      write 在类中 OutputStream
    • size

      public int size()
    • close

      public void close()
      此方法无任何效果,当流被关闭后不会抛出IOException
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Closeable
      覆盖:
      close 在类中 OutputStream
    • reset

      public void reset()
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      写出
      参数:
      out - 输出流
      抛出:
      IORuntimeException - IO异常
      IOException
    • toByteArray

      public byte[] toByteArray()
      转为Byte数组
      返回:
      Byte数组
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • toString

      public String toString(String charsetName)
      转为字符串
      参数:
      charsetName - 编码
      返回:
      字符串
    • toString

      public String toString(Charset charset)
      转为字符串
      参数:
      charset - 编码
      返回:
      字符串