public class TFileTransport extends TTransport
| Modifier and Type | Class and Description |
|---|---|
static class |
TFileTransport.ChunkState |
static class |
TFileTransport.Event |
static class |
TFileTransport.TailPolicy |
static class |
TFileTransport.TruncableBufferedInputStream |
| Modifier and Type | Field and Description |
|---|---|
protected TSeekableFile |
inputFile_
Underlying file being read
|
protected java.io.OutputStream |
outputStream_
Underlying outputStream
|
| Constructor and Description |
|---|
TFileTransport(java.lang.String path,
boolean readOnly)
File Transport ctor
|
TFileTransport(TSeekableFile inputFile,
boolean readOnly)
File Transport ctor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the transport.
|
void |
flush()
Flush any pending data out of a transport buffer.
|
int |
getCurChunk() |
int |
getNumChunks() |
TFileTransport.TailPolicy |
getTailPolicy()
Get File Tailing Policy
|
boolean |
isOpen()
open if both input/output open unless readonly
|
static void |
main(java.lang.String[] args)
test program
|
void |
open()
Diverging from the cpp model and sticking to the TSocket model
Files are not opened in ctor - but in explicit open call
|
int |
read(byte[] buf,
int off,
int len)
Reads up to len bytes into buffer buf, starting at offset off.
|
int |
readAll(byte[] buf,
int off,
int len)
Cloned from TTransport.java:readAll().
|
void |
seekToChunk(int chunk) |
void |
seekToEnd() |
TFileTransport.TailPolicy |
setTailPolicy(TFileTransport.TailPolicy policy)
Set file Tailing Policy
|
void |
write(byte[] buf,
int off,
int len)
Writes up to len bytes from the buffer.
|
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, writeprotected TSeekableFile inputFile_
protected java.io.OutputStream outputStream_
public TFileTransport(java.lang.String path,
boolean readOnly)
throws java.io.IOException
path - File path to read and write fromreadOnly - Whether this is a read-only transportjava.io.IOExceptionpublic TFileTransport(TSeekableFile inputFile, boolean readOnly)
inputFile - open TSeekableFile to read/write fromreadOnly - Whether this is a read-only transportpublic TFileTransport.TailPolicy getTailPolicy()
public TFileTransport.TailPolicy setTailPolicy(TFileTransport.TailPolicy policy)
policy - New policy to setpublic boolean isOpen()
isOpen in class TTransportpublic void open()
throws TTransportException
open in class TTransportTTransportException - if the transport could not be openedpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class TTransportpublic int readAll(byte[] buf,
int off,
int len)
throws TTransportException
readAll in class TTransportbuf - Array to read intooff - Index to start reading atlen - Maximum number of bytes to readTTransportException - if there was an error reading datapublic int read(byte[] buf,
int off,
int len)
throws TTransportException
read in class TTransportbuf - Array to read intooff - Index to start reading atlen - Maximum number of bytes to readTTransportException - if there was an error reading datapublic int getNumChunks()
throws TTransportException
TTransportExceptionpublic int getCurChunk()
throws TTransportException
TTransportExceptionpublic void seekToChunk(int chunk)
throws TTransportException
TTransportExceptionpublic void seekToEnd()
throws TTransportException
TTransportExceptionpublic void write(byte[] buf,
int off,
int len)
throws TTransportException
write in class TTransportbuf - The output data bufferoff - The offset to start writing fromlen - The number of bytes to writeTTransportException - if there was an error writing datapublic void flush()
throws TTransportException
flush in class TTransportTTransportException - if there was an error writing out data.public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception