Class StreamWriter

java.lang.Object
org.miaixz.bus.core.io.stream.StreamWriter

public class StreamWriter extends Object
OutputStream写出器
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • StreamWriter

      public StreamWriter(OutputStream out, boolean closeAfterWrite)
      构造
      Parameters:
      out - OutputStream
      closeAfterWrite - 写出结束后是否关闭流
  • Method Details

    • of

      public static StreamWriter of(OutputStream out, boolean closeAfterWrite)
      创建写出器
      Parameters:
      out - OutputStream
      closeAfterWrite - 写出结束后是否关闭流
      Returns:
      StreamReader
    • write

      public void write(byte[] content) throws InternalException
      将byte[]写到流中
      Parameters:
      content - 写入的内容
      Throws:
      InternalException - IO异常
    • writeObject

      public void writeObject(Object... contents) throws InternalException
      将多部分对象写到流中,使用ObjectOutputStream,对象必须实现序列化接口
      Parameters:
      contents - 写入的内容
      Throws:
      InternalException - IO异常
    • writeString

      public void writeString(Charset charset, Object... contents) throws InternalException
      将多部分内容写到流中,自动转换为字符串
      Parameters:
      charset - 写出的内容的字符集
      contents - 写入的内容,调用toString()方法,不包括不会自动换行
      Throws:
      InternalException - IO异常