Class TSimpleFileTransport

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

    public final class TSimpleFileTransport
    extends TEndpointTransport
    Basic file support for the TTransport interface
    • Constructor Detail

      • TSimpleFileTransport

        public TSimpleFileTransport​(java.lang.String path,
                                    boolean read,
                                    boolean write,
                                    boolean openFile)
                             throws TTransportException
        Create a transport backed by a simple file
        Parameters:
        path - the path to the file to open/create
        read - true to support read operations
        write - true to support write operations
        openFile - true to open the file on construction
        Throws:
        TTransportException - if file open fails
      • TSimpleFileTransport

        public TSimpleFileTransport​(TConfiguration config,
                                    java.lang.String path,
                                    boolean read,
                                    boolean write,
                                    boolean openFile)
                             throws TTransportException
        Create a transport backed by a simple file
        Parameters:
        config -
        path - the path to the file to open/create
        read - true to support read operations
        write - true to support write operations
        openFile - true to open the file on construction
        Throws:
        TTransportException - if file open fails
      • TSimpleFileTransport

        public TSimpleFileTransport​(java.lang.String path,
                                    boolean read,
                                    boolean write)
                             throws TTransportException
        Create a transport backed by a simple file Implicitly opens file to conform to C++ behavior.
        Parameters:
        path - the path to the file to open/create
        read - true to support read operations
        write - true to support write operations
        Throws:
        TTransportException - if file open fails
      • TSimpleFileTransport

        public TSimpleFileTransport​(java.lang.String path)
                             throws TTransportException
        Create a transport backed by a simple read only disk file (implicitly opens file)
        Parameters:
        path - the path to the file to open/create
        Throws:
        TTransportException - if file open fails
    • Method Detail

      • isOpen

        public boolean isOpen()
        Test file status
        Specified by:
        isOpen in class TTransport
        Returns:
        true if open, otherwise false
      • close

        public void close()
        Close file, subsequent read/write activity will throw exceptions
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class TTransport
      • read

        public int read​(byte[] buf,
                        int off,
                        int len)
                 throws TTransportException
        Read up to len many bytes into buf at offset
        Specified by:
        read in class TTransport
        Parameters:
        buf - houses bytes read
        off - offset into buff to begin writing to
        len - maximum number of bytes to read
        Returns:
        number of bytes actually read
        Throws:
        TTransportException - on read failure
      • write

        public void write​(byte[] buf,
                          int off,
                          int len)
                   throws TTransportException
        Write len many bytes from buff starting at offset
        Specified by:
        write in class TTransport
        Parameters:
        buf - buffer containing bytes to write
        off - offset into buffer to begin writing from
        len - number of bytes to write
        Throws:
        TTransportException - on write failure
      • seek

        public void seek​(long offset)
                  throws TTransportException
        Move file pointer to specified offset, new read/write calls will act here
        Parameters:
        offset - bytes from beginning of file to move pointer to
        Throws:
        TTransportException - is seek fails
      • getFilePointer

        public long getFilePointer()
                            throws TTransportException
        Return current file pointer position in bytes from beginning of file
        Returns:
        file pointer position
        Throws:
        TTransportException - if file access fails