Class FastByteArrayOutputStream

java.lang.Object
java.io.OutputStream
tech.mgl.core.utils.stream.FastByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class FastByteArrayOutputStream extends OutputStream
  • Constructor Details

    • FastByteArrayOutputStream

      public FastByteArrayOutputStream()
      构造
    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(int size)
      构造
      Parameters:
      size - 预估大小
  • Method Details

    • write

      public void write(byte[] b, int off, int len)
      Overrides:
      write in class OutputStream
    • write

      public void write(int b)
      Specified by:
      write in class OutputStream
    • size

      public int size()
    • close

      public void close()
      此方法无任何效果,当流被关闭后不会抛出IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
    • reset

      public void reset()
    • writeTo

      public void writeTo(OutputStream out) throws RuntimeException
      写出
      Parameters:
      out - 输出流
      Throws:
      RuntimeException - IO异常
    • toByteArray

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

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(String charsetName)
      转为字符串
      Parameters:
      charsetName - 编码
      Returns:
      字符串
    • toString

      public String toString(Charset charset)
      转为字符串
      Parameters:
      charset - 编码,null表示默认编码
      Returns:
      字符串