public class DelegatingRandomAccessFile
extends java.io.RandomAccessFile
getFilePointer method and set by the seek
method.
We need this delegating class, because due to public native methods instrumentation does not work.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
recId
Stores the (optional) recording id.
|
| Constructor and Description |
|---|
DelegatingRandomAccessFile(java.io.File file,
java.lang.String mode)
Creates a random access file stream to read from, and optionally to
write to, the file specified by the
File argument. |
DelegatingRandomAccessFile(java.io.File file,
java.lang.String mode,
java.lang.String recId)
Creates a random access file stream to read from, and optionally to
write to, the file specified by the
File argument. |
DelegatingRandomAccessFile(java.lang.String name,
java.lang.String mode)
Creates a random access file stream to read from, and optionally
to write to, a file with the specified name.
|
DelegatingRandomAccessFile(java.lang.String name,
java.lang.String mode,
java.lang.String recId)
Creates a random access file stream to read from, and optionally
to write to, a file with the specified name.
|
| Modifier and Type | Method and Description |
|---|---|
int |
read()
Reads a byte of data from this file.
|
int |
read(byte[] buffer)
Reads up to
buffer.length bytes of data from this file
into an array of bytes. |
int |
read(byte[] buffer,
int off,
int len)
Reads up to
len bytes of data from this file into an
array of bytes. |
void |
write(byte[] buffer)
Writes
buffer.length bytes from the specified byte array
to this file, starting at the current file pointer. |
void |
write(byte[] buffer,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this file. |
void |
write(int value)
Writes the specified byte to this file.
|
close, getChannel, getFD, getFilePointer, length, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, skipBytes, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFpublic DelegatingRandomAccessFile(java.lang.String name,
java.lang.String mode)
throws java.io.FileNotFoundException
FileDescriptor object is created to represent the
connection to the file.name - the system-dependent filenamemode - the access modejava.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"java.io.FileNotFoundException - if the mode is "r" but the given string does not
denote an existing regular file, or if the mode begins with
"rw" but the given string does not denote an
existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs
while opening or creating the filepublic DelegatingRandomAccessFile(java.io.File file,
java.lang.String mode)
throws java.io.FileNotFoundException
File argument. A new
FileDescriptor object is created to represent this file
connection.file - the file objectmode - the access modejava.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"java.io.FileNotFoundException - if the mode is "r" but the given file object does
not denote an existing regular file, or if the mode begins
with "rw" but the given file object does not denote
an existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs
while opening or creating the filepublic DelegatingRandomAccessFile(java.lang.String name,
java.lang.String mode,
java.lang.String recId)
throws java.io.FileNotFoundException
FileDescriptor object is created to represent the
connection to the file.name - the system-dependent filenamemode - the access moderecId - an optional recorder idjava.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"java.io.FileNotFoundException - if the mode is "r" but the given string does not
denote an existing regular file, or if the mode begins with
"rw" but the given string does not denote an
existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs
while opening or creating the filepublic DelegatingRandomAccessFile(java.io.File file,
java.lang.String mode,
java.lang.String recId)
throws java.io.FileNotFoundException
File argument. A new FileDescriptor object is created to represent this file
connection.file - the file objectmode - the access moderecId - an optional recorder idjava.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"java.io.FileNotFoundException - if the mode is "r" but the given file object does
not denote an existing regular file, or if the mode begins
with "rw" but the given file object does not denote
an existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs
while opening or creating the filepublic int read()
throws java.io.IOException
0x00-0x0ff). This
method blocks if no input is yet available.read in class java.io.RandomAccessFile-1 if the end of the
file has been reached.java.io.IOException - if an I/O error occurs. Not thrown if
end-of-file has been reached.public int read(byte[] buffer,
int off,
int len)
throws java.io.IOException
len bytes of data from this file into an
array of bytes. This method blocks until at least one byte of input
is available.read in class java.io.RandomAccessFilebuffer - the buffer into which the data is read.off - the start offset in array buffer
at which the data is written.len - the maximum number of bytes read.-1 if there is no more data because the end of
the file has been reached.java.io.IOException - If the first byte cannot be read for any reason
other than end of file, or if the random access file has been closed, or
if some other I/O error occurs.java.lang.NullPointerException - If buffer is
null.java.lang.IndexOutOfBoundsException - If off is negative,
len is negative, or len is greater than
buffer.length - offpublic int read(byte[] buffer)
throws java.io.IOException
buffer.length bytes of data from this file
into an array of bytes. This method blocks until at least one byte
of input is available.read in class java.io.RandomAccessFilebuffer - the buffer into which the data is read.-1 if there is no more data because the end of
this file has been reached.java.io.IOException - If the first byte cannot be read for any reason
other than end of file, or if the random access file has been
closed, or if some other I/O error occurs.java.lang.NullPointerException - If buffer is
null.public void write(int value)
throws java.io.IOException
write in interface java.io.DataOutputwrite in class java.io.RandomAccessFilevalue - the byte to be written.java.io.IOException - if an I/O error occurs.public void write(byte[] buffer)
throws java.io.IOException
buffer.length bytes from the specified byte array
to this file, starting at the current file pointer.write in interface java.io.DataOutputwrite in class java.io.RandomAccessFilebuffer - the data.java.io.IOException - if an I/O error occurs.public void write(byte[] buffer,
int off,
int len)
throws java.io.IOException
len bytes from the specified byte array
starting at offset off to this file.write in interface java.io.DataOutputwrite in class java.io.RandomAccessFilebuffer - the data.off - the start offset in the data.len - the number of bytes to write.java.io.IOException - if an I/O error occurs.