Class LocalTsFileInput

  • All Implemented Interfaces:
    TsFileInput

    public class LocalTsFileInput
    extends java.lang.Object
    implements TsFileInput
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalTsFileInput​(java.nio.file.Path file)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this channel.
      java.lang.String getFilePath()  
      long position()
      Returns this input's current position.
      TsFileInput position​(long newPosition)
      Sets this input's position.
      int read​(java.nio.ByteBuffer dst)
      Reads a sequence of bytes from this TsFileInput into the given buffer.
      int read​(java.nio.ByteBuffer dst, long position)
      Reads a sequence of bytes from this TsFileInput into the given buffer, starting at the given position.
      long size()
      Returns the current size of this input.
      java.io.InputStream wrapAsInputStream()  
      • Methods inherited from class java.lang.Object

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

      • LocalTsFileInput

        public LocalTsFileInput​(java.nio.file.Path file)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • size

        public long size()
                  throws java.io.IOException
        Description copied from interface: TsFileInput
        Returns the current size of this input.
        Specified by:
        size in interface TsFileInput
        Returns:
        The current size of this input, measured in bytes
        Throws:
        java.nio.channels.ClosedChannelException - If this channel is closed
        java.io.IOException - If some other I/O error occurs
      • position

        public long position()
                      throws java.io.IOException
        Description copied from interface: TsFileInput
        Returns this input's current position.
        Specified by:
        position in interface TsFileInput
        Returns:
        This input's current position, a non-negative integer counting the number of bytes from the beginning of the input to the current position
        Throws:
        java.nio.channels.ClosedChannelException - If this input is closed
        java.io.IOException - If some other I/O error occurs
      • position

        public TsFileInput position​(long newPosition)
                             throws java.io.IOException
        Description copied from interface: TsFileInput
        Sets this input's position.

        Setting the position to a value that is greater than the input's current size is legal but does not change the size of the TsFileInput. A later attempt to read bytes at such a position will immediately return an end-of-file indication.

        Specified by:
        position in interface TsFileInput
        Parameters:
        newPosition - The new position, a non-negative integer counting the number of bytes from the beginning of the TsFileInput
        Returns:
        This TsFileInput
        Throws:
        java.nio.channels.ClosedChannelException - If this TsFileInput is closed
        java.io.IOException - If some other I/O error occurs
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Description copied from interface: TsFileInput
        Reads a sequence of bytes from this TsFileInput into the given buffer.

        Bytes are read starting at this TsFileInput's current position, and then the position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the ReadableByteChannel interface.

        Specified by:
        read in interface TsFileInput
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer dst,
                        long position)
                 throws java.io.IOException
        Description copied from interface: TsFileInput
        Reads a sequence of bytes from this TsFileInput into the given buffer, starting at the given position.

        This method works in the same manner as the TsFileInput.read(ByteBuffer) method, except that bytes are read starting at the given position rather than at the TsFileInput's current position. This method does not modify this TsFileInput's position. If the given position is greater than the TsFileInput's current size then no bytes are read.

        Specified by:
        read in interface TsFileInput
        Parameters:
        dst - The buffer into which bytes are to be transferred
        position - The position at which the transfer is to begin; must be non-negative
        Returns:
        The number of bytes read, possibly zero, or -1 if the given position is greater than or equal to the file's current size
        Throws:
        java.nio.channels.ClosedChannelException - If this TsFileInput is closed
        java.nio.channels.AsynchronousCloseException - If another thread closes this TsFileInput while the read operation is in progress
        java.nio.channels.ClosedByInterruptException - If another thread interrupts the current thread while the read operation is in progress, thereby closing the channel and setting the current thread's interrupt status
        java.io.IOException - If some other I/O error occurs
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: TsFileInput
        Closes this channel.

        If the channel has already been closed then this method returns immediately.

        Specified by:
        close in interface TsFileInput
        Throws:
        java.io.IOException - If an I/O error occurs