Class OutputStream<T extends java.io.OutputStream>

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Direct Known Subclasses:
    PdfOutputStream

    public class OutputStream<T extends java.io.OutputStream>
    extends java.io.OutputStream
    • Field Detail

      • localHighPrecision

        private java.lang.Boolean localHighPrecision
      • outputStream

        protected java.io.OutputStream outputStream
      • currentPos

        protected long currentPos
      • closeStream

        protected boolean closeStream
    • Constructor Detail

      • OutputStream

        public OutputStream​(java.io.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​(java.io.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 Detail

      • 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 java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

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

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

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

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

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.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​(java.lang.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 java.io.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.