BlockedByteArray.
If the file is opened in read-only mode and the caller invokes one of the
write methods, it will fail with a NullPointerException.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | _readOnly
whether the file is read-only |
| private final BlockedByteArrayInputStream | bIn
Stream used to read from the source entry. |
| private final BlockedByteArrayOutputStream | bOut
Stream used to write into the source entry. |
| private final DataInputStream | dIs
Data input stream on top of the source input stream. |
| private final DataOutputStream | dOs
Data output stream on top of the source output stream. |
| private final DataStoreEntry | entry
The source entry. |
| private long | fp
Current position / file pointer. |
| Access | Constructor and Description |
|---|---|
| public | VirtualRandomAccessFile(DataStoreEntry
the source entry entry, boolean if the file should be opened read-only or not readOnly)Creates a new virtual random access file. |
| Modifier and Type | Method and Description |
|---|---|
| public VirtualRandomAccessFile | clone()
Overrides java. Implements org. Clone this file abstraction |
| public void | |
| public long | getFilePointer()
Implements org. Get the current offset in this file. |
| public long | length()
Implements org. Gets the length of this file. |
| public int | read(byte[]
the buffer into which the data is read. b, int the start offset in array off, int b
at which the data is written.the maximum number of bytes read. len)Implements org. Reads up to |
| public boolean | readBoolean()
Implements java. Reads one input byte and returns
|
| public byte | |
| public char | |
| public double | readDouble()
Implements java. Reads eight input bytes and returns
a |
| public float | readFloat()
Implements java. Reads four input bytes and returns
a |
| public void | readFully(byte[]
the buffer into which the data is read. b)Implements java. Reads some bytes from an input
stream and stores them into the buffer
array |
| public void | readFully(byte[]
the buffer into which the data is read. b, int an int specifying the offset in the data array off, int b.an int specifying the number of bytes to read. len)Implements java. Reads |
| public int | |
| public String | |
| public long | |
| public short | |
| public int | readUnsignedByte()
Implements java. Reads one input byte, zero-extends
it to type |
| public int | readUnsignedShort()
Implements java. Reads two input bytes and returns
an |
| public String | readUTF()
Implements java. Reads in a string that has been encoded using a modified UTF-8 format. |
| public void | seek(long
the new file pointer, measured in bytes from the beginning of the file. newFilePointer)Implements org. Set the file pointer. |
| public void | setLength(long
The new file length. newLength)Implements org. Sets the length of this file, either extending or truncating it. |
| public int | skipBytes(int
the number of bytes to be skipped. n)Implements java. Makes an attempt to skip over
|
| public void | sync()
Implements org. Force any changes out to the persistent store. |
| public void | write(int
the byte to be written. b)Implements java. Writes to the output stream the eight
low-order bits of the argument |
| public void | write(byte[]
the data. b)Implements java. Writes to the output stream all the bytes in array |
| public void | write(byte[]
the data. b, int the start offset in the data. off, int the number of bytes to write. len)Implements java. Writes |
| public void | writeBoolean(boolean
the boolean to be written. v)Implements java. Writes a |
| public void | writeByte(int
the byte value to be written. v)Implements java. Writes to the output stream the eight low-order
bits of the argument |
| public void | writeBytes(String
the string of bytes to be written. s)Implements java. Writes a string to the output stream. |
| public void | writeChar(int
the v)char value to be written.Implements java. Writes a |
| public void | writeChars(String
the string value to be written. s)Implements java. Writes every character in the string |
| public void | writeDouble(double
the v)double value to be written.Implements java. Writes a |
| public void | writeFloat(float
the v)float value to be written.Implements java. Writes a |
| public void | writeInt(int
the v)int value to be written.Implements java. Writes an |
| public void | writeLong(long
the v)long value to be written.Implements java. Writes a |
| public void | writeShort(int
the v)short value to be written.Implements java. Writes two bytes to the output stream to represent the value of the argument. |
| public void | writeUTF(String
the string value to be written. s)Implements java. Writes two bytes of length information
to the output stream, followed
by the
modified UTF-8
representation
of every character in the string |
| _readOnly | back to summary |
|---|---|
| private final boolean _readOnly whether the file is read-only | |
| bIn | back to summary |
|---|---|
| private final BlockedByteArrayInputStream bIn Stream used to read from the source entry. | |
| bOut | back to summary |
|---|---|
| private final BlockedByteArrayOutputStream bOut Stream used to write into the source entry. Will be | |
| dIs | back to summary |
|---|---|
| private final DataInputStream dIs Data input stream on top of the source input stream. | |
| dOs | back to summary |
|---|---|
| private final DataOutputStream dOs Data output stream on top of the source output stream. Will be
| |
| entry | back to summary |
|---|---|
| private final DataStoreEntry entry The source entry. | |
| fp | back to summary |
|---|---|
| private long fp Current position / file pointer. | |
| VirtualRandomAccessFile | back to summary |
|---|---|
| public VirtualRandomAccessFile(DataStoreEntry entry, boolean readOnly) throws FileNotFoundException Creates a new virtual random access file.
| |
| clone | back to summary |
|---|---|
| public VirtualRandomAccessFile clone() Overrides java. Implements org. Doc from org. Clone this file abstraction
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements org. Doc from org. Closes this file.
| |
| getFilePointer | back to summary |
|---|---|
| public long getFilePointer() Implements org. Doc from org. Get the current offset in this file.
| |
| length | back to summary |
|---|---|
| public long length() Implements org. Doc from org. Gets the length of this file.
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Implements org. Doc from org. Reads up to
| |
| readBoolean | back to summary |
|---|---|
| public boolean readBoolean() throws IOException Implements java. Doc from java. Reads one input byte and returns
| |
| readByte | back to summary |
|---|---|
| public byte readByte() throws IOException Implements java. Doc from java. Reads and returns one input byte.
The byte is treated as a signed value in
the range
| |
| readChar | back to summary |
|---|---|
| public char readChar() throws IOException Implements java. Doc from java. Reads two input bytes and returns a
This method
is suitable for reading bytes written by
the writeChar method of interface
DataOutput.
| |
| readDouble | back to summary |
|---|---|
| public double readDouble() throws IOException Implements java. Doc from java. Reads eight input bytes and returns
a
| |
| readFloat | back to summary |
|---|---|
| public float readFloat() throws IOException Implements java. Doc from java. Reads four input bytes and returns
a
| |
| readFully | back to summary |
|---|---|
| public void readFully(byte[] b) throws IOException Implements java. Doc from java. Reads some bytes from an input
stream and stores them into the buffer
array This method blocks until one of the following conditions occurs:
If
| |
| readFully | back to summary |
|---|---|
| public void readFully(byte[] b, int off, int len) throws IOException Implements java. Doc from java. Reads This method blocks until one of the following conditions occurs:
If
| |
| readInt | back to summary |
|---|---|
| public int readInt() throws IOException Implements java. Doc from java. Reads four input bytes and returns an
This method is suitable
for reading bytes written by the writeInt
method of interface DataOutput.
| |
| readLine | back to summary |
|---|---|
| public String readLine() throws IOException Implements java. Doc from java. Reads the next line of text from the input stream.
It reads successive bytes, converting
each byte separately into a character,
until it encounters a line terminator or
end of
file; the characters read are then
returned as a
If end of file is encountered
before even one byte can be read, then
| |
| readLong | back to summary |
|---|---|
| public long readLong() throws IOException Implements java. Doc from java. Reads eight input bytes and returns
a
This method is suitable
for reading bytes written by the
| |
| readShort | back to summary |
|---|---|
| public short readShort() throws IOException Implements java. Doc from java. Reads two input bytes and returns
a
This method
is suitable for reading the bytes written
by the writeShort method of
interface DataOutput.
| |
| readUnsignedByte | back to summary |
|---|---|
| public int readUnsignedByte() throws IOException Implements java. Doc from java. Reads one input byte, zero-extends
it to type
| |
| readUnsignedShort | back to summary |
|---|---|
| public int readUnsignedShort() throws IOException Implements java. Doc from java. Reads two input bytes and returns
an
This method is suitable for reading the bytes
written by the writeShort method
of interface DataOutput if
the argument to writeShort
was intended to be a value in the range
0 through 65535.
| |
| readUTF | back to summary |
|---|---|
| public String readUTF() throws IOException Implements java. Doc from java. Reads in a string that has been encoded using a
modified UTF-8
format.
The general contract of
First, two bytes are read and used to
construct an unsigned 16-bit integer in
exactly the manner of the
If the first byte of a group
matches the bit pattern
If the first byte
of a group matches the bit pattern
If the first byte of a group
matches the bit pattern 1110xxxx,
then the group consists of that byte a
and two more bytes b and c.
If there is no byte c (because
byte a was one of the last
two of the bytes to be read), or either
byte b or byte c
does not match the bit pattern 10xxxxxx,
then a UTFDataFormatException
is thrown. Otherwise, the group is converted
to the character:
If the first byte of a group matches the
pattern 1111xxxx or the pattern
10xxxxxx, then a UTFDataFormatException
is thrown.
If end of file is encountered
at any time during this entire process,
then an
After every group has been converted to
a character by this process, the characters
are gathered, in the same order in which
their corresponding groups were read from
the input stream, to form a
The
| |
| seek | back to summary |
|---|---|
| public void seek(long newFilePointer) throws IOException Implements org. Doc from org. Set the file pointer. It may be moved beyond the end of the file, but this does not change the length of the file. The length of the file is not changed until data is actually written..
| |
| setLength | back to summary |
|---|---|
| public void setLength(long newLength) Implements org. Doc from org. Sets the length of this file, either extending or truncating it. If the file is extended then the contents of the extension are not defined. If the file is truncated and the file pointer is greater than the new length then the file pointer is set to the new length.
| |
| skipBytes | back to summary |
|---|---|
| public int skipBytes(int n) Implements java. Doc from java. Makes an attempt to skip over
| |
| sync | back to summary |
|---|---|
| public void sync() Implements org. Doc from org. Force any changes out to the persistent store. If the database is to be transient, that is, if the database does not survive a restart, then the sync method implementation need not do anything. | |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements java. Doc from java. Writes to the output stream the eight
low-order bits of the argument
| |
| write | back to summary |
|---|---|
| public void write(byte[] b) throws IOException Implements java. Doc from java. Writes to the output stream all the bytes in array
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Implements java. Doc from java. Writes
| |
| writeBoolean | back to summary |
|---|---|
| public void writeBoolean(boolean v) throws IOException Implements java. Doc from java. Writes a
| |
| writeByte | back to summary |
|---|---|
| public void writeByte(int v) throws IOException Implements java. Doc from java. Writes to the output stream the eight low-order
bits of the argument
| |
| writeBytes | back to summary |
|---|---|
| public void writeBytes(String s) throws IOException Implements java. Doc from java. Writes a string to the output stream.
For every character in the string
If
| |
| writeChar | back to summary |
|---|---|
| public void writeChar(int v) throws IOException Implements java. Doc from java. Writes a
The bytes written by this method may be
read by the
| |
| writeChars | back to summary |
|---|---|
| public void writeChars(String s) throws IOException Implements java. Doc from java. Writes every character in the string
| |
| writeDouble | back to summary |
|---|---|
| public void writeDouble(double v) throws IOException Implements java. Doc from java. Writes a
| |
| writeFloat | back to summary |
|---|---|
| public void writeFloat(float v) throws IOException Implements java. Doc from java. Writes a
| |
| writeInt | back to summary |
|---|---|
| public void writeInt(int v) throws IOException Implements java. Doc from java. Writes an
The bytes written by this method may be read
by the
| |
| writeLong | back to summary |
|---|---|
| public void writeLong(long v) throws IOException Implements java. Doc from java. Writes a
The bytes written by this method may be
read by the
| |
| writeShort | back to summary |
|---|---|
| public void writeShort(int v) throws IOException Implements java. Doc from java. Writes two bytes to the output stream to represent the value of the argument. The byte values to be written, in the order shown, are:
The bytes written by this method may be
read by the
| |
| writeUTF | back to summary |
|---|---|
| public void writeUTF(String s) throws IOException Implements java. Doc from java. Writes two bytes of length information
to the output stream, followed
by the
modified UTF-8
representation
of every character in the string
If a character (byte)c
If a character If a character
First,
the total number of bytes needed to represent
all the characters of The
bytes written by this method may be read
by the
| |