public class FileBuffer extends Object implements Buffer
| Modifier and Type | Field and Description |
|---|---|
protected File | _filethe file |
protected int | _offsetthe offset |
protected int | _sublenthe sub-length |
| Constructor and Description |
|---|
FileBuffer(File file)Create a FileBuffer for the entire file. |
FileBuffer(File file,
int offset,
int sublen)Create a FileBuffer for a portion of the file. |
| Modifier and Type | Method and Description |
|---|---|
File | getFile() |
InputStream | getInputStream()Get an InputStream for the file, skipping to the offset if needed. |
int | getLength()Get the length of data in this buffer. |
int | getOffset()Get the byte offset into the file. |
OutputStream | getOutputStream()Get an OutputStream for the file. |
void | readComplete(boolean success)Close the input stream. |
String | toString() |
void | writeComplete(boolean success)Close the output stream and delete the file if success is false. |
protected final File _file
protected final int _offset
protected final int _sublen
public FileBuffer(File file)
file - the file to bufferpublic FileBuffer(File file, int offset, int sublen)
file - the file to bufferoffset - the byte offset to start reading fromsublen - the number of bytes to read, or 0 for the entire filepublic File getFile()
public InputStream getInputStream() throws IOException
getInputStream in interface BufferIOException - on I/O errorpublic int getLength()
public int getOffset()
public OutputStream getOutputStream() throws IOException
getOutputStream in interface BufferIOException - on I/O errorpublic void readComplete(boolean success)
readComplete in interface Buffersuccess - ignoredpublic void writeComplete(boolean success)
writeComplete in interface Buffersuccess - if false, deletes the file