|
Servertec Foundation Classes 1.3.3 09/04/2005 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstec.sfc.Win32.RandomAccessFile
public final class RandomAccessFile
Used to create and open random access files, to lock and unlock regions within the file, to perform seek, read and write operation on the file and to get and set the file's length.
Constructor Summary | |
---|---|
RandomAccessFile(File file,
int access_mode,
int share_mode,
int operation,
int attributes)
Constructs a new RandomAcessFile object for the specified file. |
|
RandomAccessFile(java.lang.String filename,
int access_mode,
int share_mode,
int operation,
int attributes)
Constructs a new RandomAcessFile object for the specified file. |
Method Summary | |
---|---|
void |
close()
Closes the file. |
void |
flush()
Writes buffered output to the file. |
long |
getFilePointer()
Returns the file's current offset. |
long |
length()
Return's the file's current length. |
boolean |
lock(long offset,
long bytes)
Locks the specified region. |
boolean |
lock(long offset,
long bytes,
int lock_mode)
Locks the specified region. |
int |
read()
Reads the next byte from the file. |
int |
read(byte[] buffer)
Reads as many bytes as will fit into the specified byte buffer. |
int |
read(byte[] buffer,
int bytes)
Reads the next n bytes into the specified byte buffer. |
int |
read(byte[] buffer,
int offset,
int length)
Reads the next n bytes into the specified byte buffer starting at the given offset. |
boolean |
readBoolean()
Returns the next boolean value from the file. |
byte |
readByte()
Returns the next byte value from the file. |
char |
readChar()
Returns the next character value from the file. |
java.lang.String |
readCString()
Reads the next C string from the file. |
double |
readDouble()
Returns the next long floating point value from the file. |
float |
readFloat()
Returns the next floating point value from the file. |
void |
readFully(byte[] buffer)
Reads from the specified file until the specified buffer is filled or end of file is reached. |
void |
readFully(byte[] buffer,
int offset,
int length)
Reads the specified number of bytes into the given buffer from the specified file. |
int |
readInt()
Returns the next integer value from the file. |
java.lang.String |
readLine()
Returns the next line from the file. |
long |
readLong()
Returns the next long integer value from the file. |
java.lang.Object |
readObject()
Reads the next Object from the file. |
short |
readShort()
Returns the next short value from the file. |
int |
readUnsignedByte()
Reads the next unsigned byte from the file. |
long |
readUnsignedInt()
Reads the next unsigned integer from the file. |
int |
readUnsignedShort()
Reads the next unsigned short from the file. |
java.lang.String |
readUTF()
Reads the UTF-8 encoded string from the file. |
long |
seek(long offset)
Sets the file's current offset to the specified offset relative to the begining of the file. |
long |
seek(long offset,
int origin_method)
Change the file's current offset. |
void |
seekEOF()
Sets the file pointer to end of file (EOF). |
long |
setLength(long length)
Sets the file's length. |
long |
skipBytes(long bytes)
Skips the specified number of bytes and returns the file's current offset. |
boolean |
unlock(long offset,
long bytes)
Unlocks the specified region. |
int |
write(byte[] buffer)
Writes the specified byte buffer to the file. |
int |
write(byte[] buffer,
int bytes)
Writes n bytes from the specified byte buffer to the file. |
int |
write(byte[] buffer,
int offset,
int length)
Writes n bytes from the specified byte buffer to the file starting at the given offset. |
void |
write(int byt)
Writes the specified byte to the file. |
void |
writeBoolean(boolean b)
Writes the specified boolean to the file. |
void |
writeByte(int b)
Writes the specified byte to the file. |
void |
writeBytes(java.lang.String s)
Writes the specified string as an array of bytes to the file. |
void |
writeChar(int c)
Writes the specified character to the file. |
void |
writeChars(java.lang.String s)
Writes the specified string as an array of characters to the file. |
void |
writeCString(java.lang.String s)
Writes the specified string as C string to the file. |
void |
writeDouble(double d)
Writes the specified long floating point to the file. |
void |
writeFloat(float f)
Writes the specified floating point to the file. |
void |
writeInt(int i)
Writes the specified integer to the file. |
void |
writeLine()
Writes an empty line to the file. |
void |
writeLine(java.lang.String s)
Writes the specified line to the file. |
void |
writeLong(long l)
Writes the specified long integer to the file. |
void |
writeObject(java.lang.Object o)
Writes the specified Object to the file. |
void |
writeShort(int s)
Writes the specified short to the file. |
void |
writeUTF(java.lang.String s)
Writes the specified string as an UTF-8 encoded string to the file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RandomAccessFile(File file, int access_mode, int share_mode, int operation, int attributes) throws java.io.IOException
file
- the file to create or open for random acess.access_mode
- the FileAccessMode.share_mode
- the FileShareMode.operation
- the FileOperation.attributes
- the CreateFileAttribute.
java.io.IOException
- if any error occurs.public RandomAccessFile(java.lang.String filename, int access_mode, int share_mode, int operation, int attributes) throws java.io.IOException
filename
- the file to create or open for random acess.access_mode
- the FileAccessMode.share_mode
- the FileShareMode.operation
- the FileOperation.attributes
- the CreateFileAttribute.
java.io.IOException
- if any error occurs.Method Detail |
---|
public final void close() throws java.io.IOException
java.io.IOException
- if any error occurs.public final void flush() throws java.io.IOException
java.io.IOException
- if any error occurs.public final boolean lock(long offset, long bytes) throws java.io.IOException
offset
- the starting offsetbytes
- the number of bytes to lock
java.io.IOException
- if any error occurs.public final boolean lock(long offset, long bytes, int lock_mode) throws java.io.IOException
offset
- the starting offsetbytes
- the number of bytes to locklock_mode
- the lock mode. Defined in FileLockMode.
java.io.IOException
- if any error occurs.public final boolean unlock(long offset, long bytes) throws java.io.IOException
offset
- the starting offsetbytes
- the number of bytes to unlock
java.io.IOException
- if any error occurs.public final int read() throws java.io.IOException
-1 if at end of file (EOF).
java.io.IOException
- if any error occurs.public final int read(byte[] buffer, int offset, int length) throws java.io.IOException, java.lang.IllegalArgumentException
buffer
- the byte buffer to read intooffset
- the starting offsetlength
- the number of bytes to read
-1 if at end of file (EOF).
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to read is larger than the remaining space in the specified given byte array.
java.io.IOException
- if any error occurs.public final int read(byte[] buffer, int bytes) throws java.io.IOException, java.lang.IllegalArgumentException
buffer
- the byte buffer to read intobytes
- the number of bytes to read
-1 if at end of file (EOF).
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to read is larger than the remaining space in the specified given byte array.
java.io.IOException
- if any error occurs.public final void write(int byt) throws java.io.IOException
byt
- the byte to write.
java.io.IOException
- if any error occurs.public final int write(byte[] buffer, int offset, int length) throws java.io.IOException, java.lang.IllegalArgumentException
buffer
- the byte buffer to write.offset
- the starting offsetlength
- the number of bytes to write.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to write is larger than the remaining space in the specified given byte array.
java.io.IOException
- if any error occurs.public final int write(byte[] buffer, int bytes) throws java.io.IOException, java.lang.IllegalArgumentException
buffer
- the byte buffer to write.bytes
- the number of bytes to write.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to write is larger than the remaining space in the specified given byte array.
java.io.IOException
- if any error occurs.public final long seek(long offset, int origin_method) throws java.io.IOException
offset
- the relative offset.origin_method
- the FileSeekMethod.
java.io.IOException
- if any error occurs.public final long seek(long offset) throws java.io.IOException
offset
- the offset relative to the begining of the file.
java.io.IOException
- if any error occurs.public final long getFilePointer() throws java.io.IOException
java.io.IOException
- if any error occurs.public final long skipBytes(long bytes) throws java.io.IOException
bytes
- the number of bytes to skep.
java.io.IOException
- if any error occurs.public final long length() throws java.io.IOException
java.io.IOException
- if any error occurs.public final long setLength(long length) throws java.io.IOException
length
- the new file length.
java.io.IOException
- if any error occurs.public final int read(byte[] buffer) throws java.io.IOException
buffer
- the byte buffer to read into
-1 if at end of file (EOF).
java.io.IOException
- if any error occurs.public final int write(byte[] buffer) throws java.io.IOException
buffer
- the byte buffer to write.
java.io.IOException
- if any error occurs.public final boolean readBoolean() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final byte readByte() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final short readShort() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final char readChar() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final int readInt() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final long readLong() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final float readFloat() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final double readDouble() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final java.lang.String readLine() throws java.io.IOException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeLine() throws java.io.IOException
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeLine(java.lang.String s) throws java.io.IOException
s
- the line to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void readFully(byte[] buffer, int offset, int length) throws java.io.IOException, java.io.EOFException, java.lang.IllegalArgumentException
buffer
- the buffer to read into.offset
- the starting offset into the specified buffer.length
- the number of bytes to read.
java.lang.IllegalArgumentException
- if the specified offset is less than zero or greater than or equal to the given byte array size or if the specified number of bytes to get is larger than the remaining space in the specified given byte array.
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final void readFully(byte[] buffer) throws java.io.IOException, java.io.EOFException
buffer
- the buffer to read into.
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final java.lang.String readUTF() throws java.io.IOException, java.io.EOFException, java.io.UTFDataFormatException
java.io.UTFDataFormatException
- if an encoding error occurs.
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeBoolean(boolean b) throws java.io.IOException
b
- the boolean to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeByte(int b) throws java.io.IOException
b
- the byte to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeShort(int s) throws java.io.IOException
s
- the short to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeChar(int c) throws java.io.IOException
c
- the character to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeInt(int i) throws java.io.IOException
i
- the integer to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeLong(long l) throws java.io.IOException
l
- the long integer to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeFloat(float f) throws java.io.IOException
f
- the floating point to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeDouble(double d) throws java.io.IOException
d
- the long floating point to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeBytes(java.lang.String s) throws java.io.IOException
s
- the string to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeChars(java.lang.String s) throws java.io.IOException
s
- the string to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeUTF(java.lang.String s) throws java.io.IOException, java.io.UTFDataFormatException
s
- the string to write.
java.io.IOException
- if the file has been closed or if any error occurs.
java.io.UTFDataFormatException
- if an encoding error occurs.public final int readUnsignedByte() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final int readUnsignedShort() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final long readUnsignedInt() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final java.lang.Object readObject() throws java.lang.ClassNotFoundException, java.io.IOException, java.io.EOFException
java.lang.ClassNotFoundException
- is the class of the serialized object was not found.
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeObject(java.lang.Object o) throws java.io.IOException
o
- the object to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final void writeCString(java.lang.String s) throws java.io.IOException
s
- the string to write.
java.io.IOException
- if the file has been closed or if any error occurs.public final java.lang.String readCString() throws java.io.IOException, java.io.EOFException
java.io.EOFException
- if the end of file has been reached.
java.io.IOException
- if the file has been closed or if any error occurs.public final void seekEOF() throws java.io.IOException
java.io.IOException
- if any error occurs.
|
Servertec Foundation Classes 1.3.3 09/04/2005 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2001-2005 Servertec. All rights reserved.