| java.lang.Object java.io.InputStream sun.io.RandomAccessROMFile
RandomAccessROMFile | public class RandomAccessROMFile extends InputStream implements DataInput(Code) | | Instances of this class support reading of files in ROM.
WARNING: This is not production code and is only meant as an example of
how to access files romized by JavaDataCompact. Among other things, no attempt
is made to syncronize any of the calls. This can result in errors when
two threads are trying to access the same file through the same
RandomAccessROMFile instance, or if 2 threads are trying
to open a romfile at the same time, even if each is opening a different
romfile.
|
Method Summary | |
native public void | close() Closes this random access file stream and releases any system
resources associated with the stream. | final public FileDescriptor | getFD() Returns the opaque file descriptor object associated with this stream. | native public long | getFilePointer() Returns the current offset in this file. | native public long | length() Returns the length of this file. | native public int | read() Reads a byte of data from this file. | public int | read(byte b, int off, int len) Reads up to len bytes of data from this file into an
array of bytes. | public int | read(byte b) Reads up to b.length bytes of data from this file
into an array of bytes. | final public boolean | readBoolean() Reads a boolean from this file. | final public byte | readByte() Reads a signed 8-bit value from this file. | final public char | readChar() Reads a Unicode character from this file. | final public double | readDouble() Reads a double from this file. | final public float | readFloat() Reads a float from this file. | final public void | readFully(byte b) Reads b.length bytes from this file into the byte
array. | final public void | readFully(byte b, int off, int len) Reads exactly len bytes from this file into the byte
array. | final public int | readInt() Reads a signed 32-bit integer from this file. | final public String | readLine() Reads the next line of text from this file. | final public long | readLong() Reads a signed 64-bit integer from this file. | final public short | readShort() Reads a signed 16-bit number from this file. | final public String | readUTF() Reads in a string from this file. | final public int | readUnsignedByte() Reads an unsigned 8-bit number from this file. | final public int | readUnsignedShort() Reads an unsigned 16-bit number from this file. | native public void | seek(long pos) Sets the offset from the beginning of this file at which the next
read occurs. | public int | skipBytes(int n) Skips exactly n bytes of input. |
close | native public void close() throws IOException(Code) | | Closes this random access file stream and releases any system
resources associated with the stream.
exception: IOException - if an I/O error occurs. since: JDK1.0 |
getFilePointer | native public long getFilePointer() throws IOException(Code) | | Returns the current offset in this file.
the offset from the beginning of the file, in bytes,at which the next read occurs. exception: IOException - if an I/O error occurs. since: JDK1.0 |
length | native public long length() throws IOException(Code) | | Returns the length of this file.
the length of this file. exception: IOException - if an I/O error occurs. since: JDK1.0 |
read | native public int read() throws IOException(Code) | | Reads a byte of data from this file. This method blocks if no
input is yet available.
the next byte of data, or -1 if the end of thefile is reached. exception: IOException - if an I/O error occurs. since: JDK1.0 |
read | public int read(byte b, int off, int len) throws IOException(Code) | | Reads up to len bytes of data from this file into an
array of bytes. This method blocks until at least one byte of input
is available.
Parameters: b - the buffer into which the data is read. Parameters: off - the start offset of the data. Parameters: len - the maximum number of bytes read. the total number of bytes read into the buffer, or-1 if there is no more data because the end ofthe file has been reached. exception: IOException - if an I/O error occurs. since: JDK1.0 |
read | public int read(byte b) throws IOException(Code) | | Reads up to b.length bytes of data from this file
into an array of bytes. This method blocks until at least one byte
of input is available.
Parameters: b - the buffer into which the data is read. the total number of bytes read into the buffer, or-1 if there is no more data because the end ofthis file has been reached. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readBoolean | final public boolean readBoolean() throws IOException(Code) | | Reads a boolean from this file. This method reads a
single byte from the file. A value of 0 represents
false . Any other value represents true .
This method blocks until the byte is read, the end of the stream
is detected, or an exception is thrown.
the boolean value read. exception: EOFException - if this file has reached the end. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readByte | final public byte readByte() throws IOException(Code) | | Reads a signed 8-bit value from this file. This method reads a
byte from the file. If the byte read is b , where
0 <= b <= 255 ,
then the result is:
This method blocks until the byte is read, the end of the stream
is detected, or an exception is thrown.
the next byte of this file as a signed 8-bitbyte . exception: EOFException - if this file has reached the end. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readChar | final public char readChar() throws IOException(Code) | | Reads a Unicode character from this file. This method reads two
bytes from the file. If the bytes read, in order, are
b1 and b2 , where
0 <= b1, b2 <= 255 ,
then the result is equal to:
This method blocks until the two bytes are read, the end of the
stream is detected, or an exception is thrown.
the next two bytes of this file as a Unicode character. exception: EOFException - if this file reaches the end before readingtwo bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readDouble | final public double readDouble() throws IOException(Code) | | Reads a double from this file. This method reads a
long value as if by the readLong method
and then converts that long to a double
using the longBitsToDouble method in
class Double .
This method blocks until the eight bytes are read, the end of the
stream is detected, or an exception is thrown.
the next eight bytes of this file, interpreted as adouble . exception: EOFException - if this file reaches the end before readingeight bytes. exception: IOException - if an I/O error occurs. See Also: java.io.RandomAccessFile.readLong See Also: java.lang.Double.longBitsToDouble(long) since: JDK1.0 |
readFloat | final public float readFloat() throws IOException(Code) | | Reads a float from this file. This method reads an
int value as if by the readInt method
and then converts that int to a float
using the intBitsToFloat method in class
Float .
This method blocks until the four bytes are read, the end of the
stream is detected, or an exception is thrown.
the next four bytes of this file, interpreted as afloat . exception: EOFException - if this file reaches the end before readingfour bytes. exception: IOException - if an I/O error occurs. See Also: java.io.RandomAccessFile.readInt See Also: java.lang.Float.intBitsToFloat(int) since: JDK1.0 |
readFully | final public void readFully(byte b) throws IOException(Code) | | Reads b.length bytes from this file into the byte
array. This method reads repeatedly from the file until all the
bytes are read. This method blocks until all the bytes are read,
the end of the stream is detected, or an exception is thrown.
Parameters: b - the buffer into which the data is read. exception: EOFException - if this file reaches the end before readingall the bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readFully | final public void readFully(byte b, int off, int len) throws IOException(Code) | | Reads exactly len bytes from this file into the byte
array. This method reads repeatedly from the file until all the
bytes are read. This method blocks until all the bytes are read,
the end of the stream is detected, or an exception is thrown.
Parameters: b - the buffer into which the data is read. Parameters: off - the start offset of the data. Parameters: len - the number of bytes to read. exception: EOFException - if this file reaches the end before readingall the bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readInt | final public int readInt() throws IOException(Code) | | Reads a signed 32-bit integer from this file. This method reads 4
bytes from the file. If the bytes read, in order, are b1 ,
b2 , b3 , and b4 , where
0 <= b1, b2, b3, b4 <= 255 ,
then the result is equal to:
(b1 << 24) | (b2 << 16) + (b3 << 8) + b4
This method blocks until the four bytes are read, the end of the
stream is detected, or an exception is thrown.
the next four bytes of this file, interpreted as anint . exception: EOFException - if this file reaches the end before readingfour bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readLine | final public String readLine() throws IOException(Code) | | Reads the next line of text from this file. This method
successively reads bytes from the file until it reaches the end of
a line of text.
A line of text is terminated by a carriage-return character
('\r' ), a newline character ('\n' ), a
carriage-return character immediately followed by a newline
character, or the end of the input stream. The line-terminating
character(s), if any, are included as part of the string returned.
This method blocks until a newline character is read, a carriage
return and the byte following it are read (to see if it is a
newline), the end of the stream is detected, or an exception is thrown.
the next line of text from this file. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readLong | final public long readLong() throws IOException(Code) | | Reads a signed 64-bit integer from this file. This method reads eight
bytes from the file. If the bytes read, in order, are
b1 , b2 , b3 ,
b4 , b5 , b6 ,
b7 , and b8, where:
0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,
then the result is equal to:
((long)b1 << 56) + ((long)b2 << 48)
+ ((long)b3 << 40) + ((long)b4 << 32)
+ ((long)b5 << 24) + ((long)b6 << 16)
+ ((long)b7 << 8) + b8
This method blocks until the eight bytes are read, the end of the
stream is detected, or an exception is thrown.
the next eight bytes of this file, interpreted as along . exception: EOFException - if this file reaches the end before readingeight bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readShort | final public short readShort() throws IOException(Code) | | Reads a signed 16-bit number from this file. The method reads 2
bytes from this file. If the two bytes read, in order, are
b1 and b2 , where each of the two values is
between 0 and 255 , inclusive, then the
result is equal to:
This method blocks until the two bytes are read, the end of the
stream is detected, or an exception is thrown.
the next two bytes of this file, interpreted as a signed16-bit number. exception: EOFException - if this file reaches the end before readingtwo bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readUTF | final public String readUTF() throws IOException(Code) | | Reads in a string from this file. The string has been encoded
using a modified UTF-8 format.
The first two bytes are read as if by
readUnsignedShort . This value gives the number of
following bytes that are in the encoded string, not
the length of the resulting string. The following bytes are then
interpreted as bytes encoding characters in the UTF-8 format
and are converted into characters.
This method blocks until all the bytes are read, the end of the
stream is detected, or an exception is thrown.
a Unicode string. exception: EOFException - if this file reaches the end beforereading all the bytes. exception: IOException - if an I/O error occurs. exception: UTFDataFormatException - if the bytes do not represent valid UTF-8 encoding of a Unicode string. See Also: java.io.RandomAccessFile.readUnsignedShort since: JDK1.0 |
readUnsignedByte | final public int readUnsignedByte() throws IOException(Code) | | Reads an unsigned 8-bit number from this file. This method reads
a byte from this file and returns that byte.
This method blocks until the byte is read, the end of the stream
is detected, or an exception is thrown.
the next byte of this file, interpreted as an unsigned8-bit number. exception: EOFException - if this file has reached the end. exception: IOException - if an I/O error occurs. since: JDK1.0 |
readUnsignedShort | final public int readUnsignedShort() throws IOException(Code) | | Reads an unsigned 16-bit number from this file. This method reads
two bytes from the file. If the bytes read, in order, are
b1 and b2 , where
0 <= b1, b2 <= 255 ,
then the result is equal to:
This method blocks until the two bytes are read, the end of the
stream is detected, or an exception is thrown.
the next two bytes of this file, interpreted as an unsigned16-bit integer. exception: EOFException - if this file reaches the end before readingtwo bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
seek | native public void seek(long pos) throws IOException(Code) | | Sets the offset from the beginning of this file at which the next
read occurs.
Parameters: pos - the absolute position. exception: IOException - if an I/O error occurs. since: JDK1.0 |
skipBytes | public int skipBytes(int n) throws IOException(Code) | | Skips exactly n bytes of input.
This method blocks until all the bytes are skipped, the end of
the stream is detected, or an exception is thrown.
Parameters: n - the number of bytes to be skipped. the number of bytes skipped, which is always n . exception: EOFException - if this file reaches the end before skippingall the bytes. exception: IOException - if an I/O error occurs. since: JDK1.0 |
|
|