Class HighPrecisionOutputStreamOutputStream>

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

public class HighPrecisionOutputStreamOutputStream> extends OutputStream
Output stream based on OutputStream for which it is possible to set high precision in order to write all floats and doubles with high precision.
  • Field Details

    • outputStream

      protected OutputStream outputStream
    • currentPos

      protected long currentPos
    • closeStream

      protected boolean closeStream
  • Constructor Details

    • HighPrecisionOutputStream

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

      public HighPrecisionOutputStream (OutputStream outputStream, boolean localHighPrecision)
      Creates a new HighPrecisionOutputStream 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 HighPrecisionOutputStream instances.
      Parameters:
      value - if true, all floats and double will be written with high precision in all HighPrecisionOutputStream 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 HighPrecisionOutputStream. 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 HighPrecisionOutputStream.
    • 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 HighPrecisionOutputStream is not a ByteArrayOutputStream instance.