Class OutputStreamOutputStream>

java.lang.Object
java.io.OutputStream
com.itextpdf.io.source.OutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Direct Known Subclasses:
PdfOutputStream

public class OutputStreamOutputStream> extends OutputStream
  • Field Details

    • outputStream

      protected OutputStream outputStream
    • currentPos

      protected long currentPos
    • closeStream

      protected boolean closeStream
  • Constructor Details

    • OutputStream

      public OutputStream (OutputStream outputStream)
      Creates a new OutputStream instance based on OutputStream instance.
      Parameters:
      outputStream - the OutputStream instance.
    • OutputStream

      protected OutputStream()
      Do not use this constructor. This is only for internal usage.
    • OutputStream

      public OutputStream (OutputStream outputStream, boolean localHighPrecision)
      Creates a new OutputStream instance based on OutputStream instance and precision setting value.
      Parameters:
      outputStream - the OutputStream instance.
      localHighPrecision - If true, all float and double values will be written with high precision. Global ByteUtils.HighPrecision setting will be overridden by this one.
  • Method Details

    • getHighPrecision

      public static boolean getHighPrecision()
      Gets global high precision setting.
      Returns:
      global high precision setting.
    • setHighPrecision

      public static void setHighPrecision (boolean value)
      Sets global high precision setting for all OutputStream instances.
      Parameters:
      value - if true, all floats and double will be written with high precision in all OutputStream instances.
    • getLocalHighPrecision

      public boolean getLocalHighPrecision()
      Gets local high precision setting.
      Returns:
      local high precision setting.
    • setLocalHighPrecision

      public void setLocalHighPrecision (boolean value)
      Sets local high precision setting for the OutputStream. Global ByteUtils.HighPrecision setting will be overridden by this one.
      Parameters:
      value - if true, all floats and double will be written with high precision in the underlying OutputStream.
    • write

      public void write (int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write (byte[] b) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • write

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

      public void writeByte (byte value)
      Parameters:
      value - byte to write.
      Throws:
      IOException - if IOException occurs.
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • writeLong

      public T writeLong (long value)
      Writes long to internal OutputStream in ISO format.
      Parameters:
      value - value to write.
      Returns:
      this stream as passed generic stream.
    • writeInteger

      public T writeInteger (int value)
      Writes int to internal OutputStream in ISO format.
      Parameters:
      value - value to write.
      Returns:
      this stream as passed generic stream.
    • writeFloat

      public T writeFloat (float value)
      Writes float to internal OutputStream in ISO format.
      Parameters:
      value - value to write.
      Returns:
      this stream as passed generic stream.
    • writeFloat

      public T writeFloat (float value, boolean highPrecision)
      Writes float to internal OutputStream in ISO format.
      Parameters:
      value - value to write.
      highPrecision - If true, float value will be written with high precision.
      Returns:
      this stream as passed generic stream.
    • writeFloats

      public T writeFloats (float[] value)
      Writes float array to internal OutputStream in ISO format.
      Parameters:
      value - float array to write.
      Returns:
      this stream as passed generic stream.
    • writeDouble

      public T writeDouble (double value)
      Writes double to internal OutputStream in ISO format.
      Parameters:
      value - value to write.
      Returns:
      this stream as passed generic stream.
    • writeDouble

      public T writeDouble (double value, boolean highPrecision)
      Writes double to internal OutputStream in ISO format.
      Parameters:
      value - value to write.
      highPrecision - If true, double value will be written with high precision.
      Returns:
      this stream as passed generic stream.
    • writeByte

      public T writeByte (int value)
      Writes byte to internal OutputStream.
      Parameters:
      value - value to write.
      Returns:
      this stream as passed generic stream.
    • writeSpace

      public T writeSpace()
      Writes space to internal OutputStream.
      Returns:
      this stream as passed generic stream.
    • writeNewLine

      public T writeNewLine()
      Writes new line to internal OutputStream.
      Returns:
      this stream as passed generic stream.
    • writeString

      public T writeString (String value)
      Writes String to internal OutputStream in ISO format.
      Parameters:
      value - string to write.
      Returns:
      this stream as passed generic stream.
    • writeBytes

      public T writeBytes (byte[] b)
      Parameters:
      b - byte array to write.
      Returns:
      this stream as passed generic stream.
      Throws:
      IOException - if IOException is thrown.
    • writeBytes

      public T writeBytes (byte[] b, int off, int len)
      Parameters:
      b - the data to write.
      off - the start offset in the data.
      len - the number of bytes to write.
      Returns:
      this stream as passed generic stream.
      Throws:
      IOException - if IOException is thrown.
    • getCurrentPos

      public long getCurrentPos()
      Gets current output stream position.
      Returns:
      current output stream position.
    • getOutputStream

      public OutputStream getOutputStream()
      Gets internal OutputStream.
      Returns:
      internal OutputStream.
    • isCloseStream

      public boolean isCloseStream()
      Returns true, if internal OutputStream have to be closed after close() call, false otherwise.
      Returns:
      true if stream needs to be closed, false if it's done manually.
    • setCloseStream

      public void setCloseStream (boolean closeStream)
      Sets internal OutputStream to be closed after close().
      Parameters:
      closeStream - true if stream needs to be closed, false if it's done manually.
    • assignBytes

      public void assignBytes (byte[] bytes, int count)
      Parameters:
      bytes - bytes to assign.
      count - number of bytes to assign.
    • reset

      public void reset()
      Throws:
      IOException - if internal OutputStream. is not a ByteArrayOutputStream instance.