public class FileAccessor extends Object implements DataAccessor
Constructor and Description |
---|
FileAccessor(File file)
Creates a new instance of FileAccessor
|
Modifier and Type | Method and Description |
---|---|
void |
append(byte[] buffer,
int off,
int len)
Appends exactly
len bytes, starting at off of the buffer pointer
to the end of file resource. |
void |
close()
Closes DataAccessor file resource
|
int |
getFileLength() |
long |
getFilePointer()
Returns the current offset in this file.
|
void |
open(boolean requestWrite)
Opens DataAccessor file resource
|
void |
read(byte[] buffer,
int off,
int len)
Reads up to len bytes of data from this file resource into an array of bytes.
|
void |
resetFile()
Clears the file and sets the offset to 0
|
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this
file, at which the next read or write occurs.
|
String |
toString() |
public FileAccessor(File file)
public void append(byte[] buffer, int off, int len) throws IOException
len
bytes, starting at off
of the buffer pointer
to the end of file resource.append
in interface DataAccessor
buffer
- the buffer from which the data is appended.off
- the start offset of the data in the buffer.len
- the number of bytes to append.IOException
public void read(byte[] buffer, int off, int len) throws IOException
read
in interface DataAccessor
buffer
- the buffer into which the data is read.off
- the start offset of the data.len
- the maximum number of bytes read.IOException
public void open(boolean requestWrite) throws IOException
open
in interface DataAccessor
requestWrite
- if true, file is opened for read/write operation.IOException
public void close() throws IOException
close
in interface DataAccessor
IOException
public long getFilePointer() throws IOException
getFilePointer
in interface DataAccessor
IOException
public void resetFile() throws IOException
resetFile
in interface DataAccessor
IOException
public void seek(long pos) throws IOException
DataAccessor
seek
in interface DataAccessor
IOException
public int getFileLength()
getFileLength
in interface DataAccessor