Class LocalTsFileOutput

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable, TsFileOutput

    public class LocalTsFileOutput
    extends java.io.OutputStream
    implements TsFileOutput
    a TsFileOutput implementation with FileOutputStream. If the file is not existed, it will be created. Otherwise the file will be written from position 0.
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalTsFileOutput​(java.io.FileOutputStream outputStream)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      close the output.
      void flush()
      the same with OutputStream.flush().
      long getPosition()
      gets the current position of the Output.
      void truncate​(long size)
      The same with FileChannel.truncate(long).
      java.io.OutputStream wrapAsStream()
      convert this TsFileOutput as a outputstream.
      void write​(byte b)
      Writes 1 byte to this output at the current position.
      void write​(byte[] b)
      Writes b.length bytes from the specified byte array to this output at the current position.
      void write​(byte[] buf, int start, int offset)  
      void write​(int b)  
      void write​(java.nio.ByteBuffer b)
      Writes b.remaining() bytes from the specified byte array to this output at the current position.
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalTsFileOutput

        public LocalTsFileOutput​(java.io.FileOutputStream outputStream)
    • Method Detail

      • 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
        Description copied from interface: TsFileOutput
        Writes b.length bytes from the specified byte array to this output at the current position.
        Specified by:
        write in interface TsFileOutput
        Overrides:
        write in class java.io.OutputStream
        Parameters:
        b - the data.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        public void write​(byte b)
                   throws java.io.IOException
        Description copied from interface: TsFileOutput
        Writes 1 byte to this output at the current position.
        Specified by:
        write in interface TsFileOutput
        Parameters:
        b - the data.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        public void write​(byte[] buf,
                          int start,
                          int offset)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(java.nio.ByteBuffer b)
                   throws java.io.IOException
        Description copied from interface: TsFileOutput
        Writes b.remaining() bytes from the specified byte array to this output at the current position.
        Specified by:
        write in interface TsFileOutput
        Parameters:
        b - the data.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • getPosition

        public long getPosition()
        Description copied from interface: TsFileOutput
        gets the current position of the Output. This method is usually used for recording where the data is.
        For example, if the Output is a fileOutputStream, then getPosition returns its file position.
        Specified by:
        getPosition in interface TsFileOutput
        Returns:
        current position
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: TsFileOutput
        close the output.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface TsFileOutput
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException - if an I/O error occurs.
      • wrapAsStream

        public java.io.OutputStream wrapAsStream()
        Description copied from interface: TsFileOutput
        convert this TsFileOutput as a outputstream.
        Specified by:
        wrapAsStream in interface TsFileOutput
        Returns:
        an output stream whose position is the same with this Output
      • flush

        public void flush()
                   throws java.io.IOException
        Description copied from interface: TsFileOutput
        the same with OutputStream.flush().
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in interface TsFileOutput
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException - if an I/O error occurs.
      • truncate

        public void truncate​(long size)
                      throws java.io.IOException
        Description copied from interface: TsFileOutput
        The same with FileChannel.truncate(long).
        Specified by:
        truncate in interface TsFileOutput
        Parameters:
        size - size The new size, a non-negative byte count
        Throws:
        java.io.IOException