@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public class ByteArrayReadOnlyFile extends AbstractReadOnlyFile
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
buffer |
private int |
limit |
private int |
position |
private int |
start |
| Constructor and Description |
|---|
ByteArrayReadOnlyFile(byte[] buf)
Constructs a new byte array read only file.
|
ByteArrayReadOnlyFile(byte[] buffer,
int offset,
int length)
Constructs a new byte array read only file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this read-only file and releases any non-heap resources
allocated for it.
|
long |
getFilePointer()
Returns the current byte position in the file as a zero-based index.
|
long |
length()
Returns the length of the file in bytes.
|
int |
read()
Reads and returns the next byte or -1 if the end of the file has been
reached.
|
int |
read(byte[] buffer,
int offset,
int remaining)
Reads up to
len bytes of data from this read only file into
the given array. |
void |
seek(long pos)
Sets the current byte position in the file as a zero-based index at
which the next read occurs.
|
read, readFully, readFullyprivate final byte[] buffer
private final int start
private int position
private int limit
public ByteArrayReadOnlyFile(byte[] buf)
buf - the array to read from.
Note that this array is not copied, so beware of
concurrent modifications!public ByteArrayReadOnlyFile(byte[] buffer,
int offset,
int length)
buffer - the array to read from.
Note that this array is not copied, so beware of
concurrent modifications!offset - the start of the window to read from the array.length - the length of the window to read from the array.public long length()
ReadOnlyFilepublic long getFilePointer()
ReadOnlyFilepublic void seek(long pos)
throws IOException
ReadOnlyFileDefaultReadOnlyFile subclass
RandomAccessFile passes "r" as a parameter to
the superclass constructor.
With Sun's JSE implementation, on the Windows platform this
implementation allows to seek past the end of file, but on the Linux
platform it doesn't.pos - The current byte position as a zero-based index.IOException - If pos is less than 0 or if
an I/O error occurs.public int read()
ReadOnlyFilepublic int read(byte[] buffer,
int offset,
int remaining)
ReadOnlyFilelen bytes of data from this read only file into
the given array.
This method blocks until at least one byte of input is available.buffer - The buffer to fill with data.offset - The start offset of the data.remaining - The maximum number of bytes to read.-1 if there is
no more data because the end of the file has been reached.public void close()
throws IOException
ReadOnlyFileIOExceptionCopyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.