|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.sdsc.grid.io.GeneralRandomAccessFile
edu.sdsc.grid.io.local.LocalRandomAccessFile
public class LocalRandomAccessFile
A wrapper class for java.io.RandomAccessFile.
RandomAccessFile,
GeneralRandomAccessFile| Field Summary |
|---|
| Fields inherited from class edu.sdsc.grid.io.GeneralRandomAccessFile |
|---|
fd, file, fileFormat, isClosed, mode, rw, SEEK_CURRENT, SEEK_END, SEEK_START, swapNeeded |
| Constructor Summary | |
|---|---|
LocalRandomAccessFile(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. |
|
LocalRandomAccessFile(LocalFile file,
java.lang.String mode)
Creates a random access file stream to read from, and optionally to write to, the file specified by the LocalFile argument. |
|
LocalRandomAccessFile(java.lang.String name,
java.lang.String mode)
Creates a random access file stream to read from, and optionally to write to, the file specified by the String argument. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this random access file stream and releases any system resources associated with the stream. |
long |
getFilePointer()
Returns the current offset in this file. |
java.io.RandomAccessFile |
getRandomAccessFile()
Returns this object as a standard java.io.RandomAccessFile. |
long |
length()
Returns the length of this file. |
protected void |
open(GeneralFile file)
Opens a file and returns the file descriptor. |
int |
read()
Reads a byte of data from this file. |
protected int |
readBytes(byte[] b,
int offset,
int len)
Reads a sub array as a sequence of bytes. |
void |
seek(long position)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. |
void |
seek(long position,
int origin)
Sets the file-pointer offset at which the next read or write occurs. |
void |
setLength(long newLength)
Sets the length of this file. |
int |
skipBytes(int n)
Attempts to skip over n bytes of input discarding the
skipped bytes. |
void |
write(int b)
Writes the specified byte to this file. |
protected void |
writeBytes(byte[] b,
int offset,
int len)
Writes a sub array as a sequence of bytes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LocalRandomAccessFile(java.lang.String name,
java.lang.String mode)
throws java.io.IOException
String argument. A new
file descriptor is obtained which represents the connection to the file.
The mode argument specifies the access mode in which the file is to be opened. The permitted values and their meanings are:
On construction a check is made to see if read access to the file is allowed. If the mode allows writing, write access to the file is also checked.
"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOExceptionto be thrown."rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it. "rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device. "rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.
file - the file objectmode - the access mode, as described
above
java.io.IOException - If an I/O error occurs
java.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"
java.io.FileNotFoundException - If the file exists but is a directory
rather than a regular file, or cannot be opened or
created for any other reason
java.lang.SecurityException - If denied read access to the file
or the mode is "rw" and denied write access to the file.
public LocalRandomAccessFile(java.io.File file,
java.lang.String mode)
throws java.io.IOException
File argument. A new
file descriptor is obtained which represents the connection to the file.
The mode argument specifies the access mode in which the file is to be opened. The permitted values and their meanings are:
On construction a check is made to see if read access to the file is allowed. If the mode allows writing, write access to the file is also checked.
"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOExceptionto be thrown."rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it. "rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device. "rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.
file - the file objectmode - the access mode, as described
above
java.io.IOException - If an I/O error occurs
java.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"
java.io.FileNotFoundException - If the file exists but is a directory
rather than a regular file, or cannot be opened or
created for any other reason
java.lang.SecurityException - If denied read access to the file
or the mode is "rw" and denied write access to the file.
public LocalRandomAccessFile(LocalFile file,
java.lang.String mode)
throws java.io.IOException
LocalFile argument. A new
file descriptor is obtained which represents the connection to the file.
The mode argument specifies the access mode in which the file is to be opened. The permitted values and their meanings are:
On construction a check is made to see if read access to the file is allowed. If the mode allows writing, write access to the file is also checked.
"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOExceptionto be thrown."rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it. "rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device. "rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.
file - the file objectmode - the access mode, as described
above
java.io.IOException - If an I/O error occurs
java.lang.IllegalArgumentException - if the mode argument is not equal
to one of "r", "rw", "rws", or
"rwd"
java.io.FileNotFoundException - If the file exists but is a directory
rather than a regular file, or cannot be opened or
created for any other reason
java.lang.SecurityException - If denied read access to the file
or the mode is "rw" and denied write access to the file.| Method Detail |
|---|
public java.io.RandomAccessFile getRandomAccessFile()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.RandomAccessFile
protected void open(GeneralFile file)
throws java.io.FileNotFoundException
GeneralRandomAccessFilename refers to a directory, an IOException
is thrown.
open in class GeneralRandomAccessFilejava.io.FileNotFoundException
public int read()
throws java.io.IOException
GeneralRandomAccessFile0x00-0x0ff). This
method blocks if no input is yet available.
Although GeneralRandomAccessFile is not a subclass of
InputStream, this method behaves in exactly the same
way as java.io.InputStream.read().
read in class GeneralRandomAccessFile-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.
protected int readBytes(byte[] b,
int offset,
int len)
throws java.io.IOException
GeneralRandomAccessFile
readBytes in class GeneralRandomAccessFileb - the data to be writtenlen - the number of bytes that are written
java.io.IOException - If an I/O error has occurred.
public int skipBytes(int n)
throws java.io.IOException
GeneralRandomAccessFilen bytes of input discarding the
skipped bytes.
This method may skip over some smaller number of bytes, possibly zero.
This may result from any of a number of conditions; reaching end of
file before n bytes have been skipped is only one
possibility. This method never throws an EOFException.
The actual number of bytes skipped is returned. If n
is negative, no bytes are skipped.
skipBytes in interface java.io.DataInputskipBytes in class GeneralRandomAccessFilen - the number of bytes to be skipped.
java.io.IOException - if an I/O error occurs.
public void write(int b)
throws java.io.IOException
GeneralRandomAccessFile
write in interface java.io.DataOutputwrite in class GeneralRandomAccessFileb - the byte to be written.
java.io.IOException - if an I/O error occurs.
protected void writeBytes(byte[] b,
int offset,
int len)
throws java.io.IOException
GeneralRandomAccessFile
writeBytes in class GeneralRandomAccessFileb - the data to be writtenlen - the number of bytes that are written
java.io.IOException - If an I/O error has occurred.
public long getFilePointer()
throws java.io.IOException
getFilePointer in class GeneralRandomAccessFilejava.io.IOException - if an I/O error occurs.
public void seek(long position)
throws java.io.IOException
seek in class GeneralRandomAccessFilepos - the offset position, measured in bytes from the
beginning of the file, at which to set the file
pointer.
java.io.IOException - if pos is less than
0 or if an I/O error occurs.
public void seek(long position,
int origin)
throws java.io.IOException
seek in class GeneralRandomAccessFilepos - the offset position, measured in bytes from the
at which to set the file pointer.origin - a Sets offset for the beginning of the seek.java.io.IOException - if pos is less than
0 or if an I/O error occurs.
public long length()
throws java.io.IOException
length in class GeneralRandomAccessFilejava.io.IOException - if an I/O error occurs.
public void setLength(long newLength)
throws java.io.IOException
If the present length of the file as returned by the
length method is greater than the newLength
argument then the file will be truncated. In this case, if the file
offset as returned by the getFilePointer method is greater
then newLength then after this method returns the offset
will be equal to newLength.
If the present length of the file as returned by the
length method is smaller than the newLength
argument then the file will be extended. In this case, the contents of
the extended portion of the file are not defined.
setLength in class GeneralRandomAccessFilenewLength - The desired length of the file
java.io.IOException - If an I/O error occurs
public void close()
throws java.io.IOException
close in class GeneralRandomAccessFilejava.io.IOException - if an I/O error occurs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||