public class BufferedRandomAccessFile
extends java.lang.Object
implements java.io.DataInput, java.io.DataOutput
com.objectwave.persist.FileBroker .
Publically identical to java.io.RandomAccessFile , except for
the constuctor and flush() . Note: This class is not threadsafe.
Modifications by Philip R. Burns. 2007/05/08.
| Modifier and Type | Class and Description |
|---|---|
protected class |
BufferedRandomAccessFile.FileBufferStruct |
| Modifier and Type | Field and Description |
|---|---|
protected BufferedRandomAccessFile.FileBufferStruct |
altBuf |
protected BufferedRandomAccessFile.FileBufferStruct |
currBuf |
(package private) java.io.RandomAccessFile |
delegate |
| Modifier | Constructor and Description |
|---|---|
protected |
BufferedRandomAccessFile(java.io.File file,
java.lang.String mode)
Constructor for the BufferedRandomAccessFile object
|
|
BufferedRandomAccessFile(java.io.File file,
java.lang.String mode,
int bufferSize)
Constructor for the BufferedRandomAccessFile object
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Description of the Method
|
protected void |
commitBuffer()
If modified, write buffered bytes to the delegate file
|
protected void |
fillBuffer()
Description of the Method
|
void |
flush()
Description of the Method
|
java.io.FileDescriptor |
getFD()
Gets the FD attribute of the BufferedRandomAccessFile object
|
long |
getFilePointer()
Gets the FilePointer attribute of the BufferedRandomAccessFile object
|
java.io.Reader |
getReader()
Gets the Reader attribute of the BufferedRandomAccessFile object
|
java.io.Writer |
getWriter()
Gets the Writer attribute of the BufferedRandomAccessFile object
|
long |
length()
Description of the Method
|
int |
read()
Description of the Method
|
int |
read(byte[] b)
Description of the Method
|
int |
read(byte[] b,
int pos,
int len)
Description of the Method
|
boolean |
readBoolean()
Description of the Method
|
byte |
readByte()
Description of the Method
|
char |
readChar()
Description of the Method
|
double |
readDouble()
Description of the Method
|
float |
readFloat()
Description of the Method
|
void |
readFully(byte[] b)
Description of the Method
|
void |
readFully(byte[] b,
int pos,
int len)
Description of the Method
|
int |
readInt()
Description of the Method
|
java.lang.String |
readLine()
Description of the Method
|
long |
readLong()
Description of the Method
|
short |
readShort()
Description of the Method
|
int |
readUnsignedByte()
Description of the Method
|
int |
readUnsignedShort()
Description of the Method
|
java.lang.String |
readUTF()
Description of the Method
|
void |
seek(long pos)
Description of the Method
|
void |
setLength(long newLength)
Sets the Length attribute of the BufferedRandomAccessFile object
|
int |
skipBytes(int n)
Description of the Method
|
long |
skipBytes(long n)
Description of the Method
|
protected int |
syncBuffer(long new_FP)
Save any changes and re-read the currBuf.bytes from the given position.
|
void |
write(byte[] b)
Description of the Method
|
void |
write(byte[] b,
int pos,
int len)
Description of the Method
|
void |
write(int b)
Description of the Method
|
void |
writeBoolean(boolean b)
Description of the Method
|
void |
writeByte(int b)
Description of the Method
|
void |
writeBytes(java.lang.String s)
Description of the Method
|
void |
writeChar(int ch)
Description of the Method
|
void |
writeChars(java.lang.String s)
Description of the Method
|
void |
writeDouble(double f)
Description of the Method
|
void |
writeFloat(float f)
Description of the Method
|
void |
writeInt(int i)
Description of the Method
|
void |
writeLong(long l)
Description of the Method
|
void |
writeShort(int s)
Description of the Method
|
void |
writeUTF(java.lang.String str)
Description of the Method
|
protected BufferedRandomAccessFile.FileBufferStruct currBuf
protected BufferedRandomAccessFile.FileBufferStruct altBuf
java.io.RandomAccessFile delegate
public BufferedRandomAccessFile(java.io.File file,
java.lang.String mode,
int bufferSize)
throws java.io.IOException
file - Description of Parametermode - Description of ParameterbufferSize - Description of Parameterjava.io.IOException - Description of Exceptionprotected BufferedRandomAccessFile(java.io.File file,
java.lang.String mode)
throws java.io.IOException
file - Description of Parametermode - Description of Parameterjava.io.IOException - Description of Exceptionpublic void setLength(long newLength)
throws java.io.IOException
newLength - The new Length valuejava.io.IOException - Description of Exceptionpublic java.io.Reader getReader()
public java.io.Writer getWriter()
public java.io.FileDescriptor getFD()
throws java.io.IOException
java.io.IOException - Description of Exceptionpublic long getFilePointer()
public boolean readBoolean()
throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic byte readByte()
throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic java.lang.String readLine()
throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.IOException - Description of Exceptionpublic void writeBoolean(boolean b)
throws java.io.IOException
writeBoolean in interface java.io.DataOutputb - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeByte(int b)
throws java.io.IOException
writeByte in interface java.io.DataOutputb - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeShort(int s)
throws java.io.IOException
writeShort in interface java.io.DataOutputs - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeChar(int ch)
throws java.io.IOException
writeChar in interface java.io.DataOutputch - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeInt(int i)
throws java.io.IOException
writeInt in interface java.io.DataOutputi - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeLong(long l)
throws java.io.IOException
writeLong in interface java.io.DataOutputl - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeFloat(float f)
throws java.io.IOException
writeFloat in interface java.io.DataOutputf - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeDouble(double f)
throws java.io.IOException
writeDouble in interface java.io.DataOutputf - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeUTF(java.lang.String str)
throws java.io.IOException
writeUTF in interface java.io.DataOutputstr - Description of Parameterjava.io.IOException - Description of Exceptionpublic void readFully(byte[] b)
throws java.io.IOException
readFully in interface java.io.DataInputb - Description of Parameterjava.io.IOException - Description of Exceptionpublic void readFully(byte[] b,
int pos,
int len)
throws java.io.IOException
readFully in interface java.io.DataInputb - Description of Parameterpos - Description of Parameterlen - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputs - Description of Parameterjava.io.IOException - Description of Exceptionpublic void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface java.io.DataOutputs - Description of Parameterjava.io.IOException - Description of Exceptionpublic long length()
throws java.io.IOException
java.io.IOException - Description of Exceptionpublic int read()
throws java.io.IOException
java.io.IOException - Description of Exceptionpublic int read(byte[] b)
throws java.io.IOException
b - Description of Parameterjava.io.IOException - Description of Exceptionpublic int read(byte[] b,
int pos,
int len)
throws java.io.IOException
b - Description of Parameterpos - Description of Parameterlen - Description of Parameterjava.io.IOException - Description of Exceptionpublic void seek(long pos)
throws java.io.IOException
pos - Description of Parameterjava.io.IOException - Description of Exceptionpublic int skipBytes(int n)
throws java.io.IOException
skipBytes in interface java.io.DataInputn - Description of Parameterjava.io.IOException - Description of Exceptionpublic long skipBytes(long n)
throws java.io.IOException
n - Description of Parameterjava.io.IOException - Description of Exceptionpublic void write(byte[] b)
throws java.io.IOException
write in interface java.io.DataOutputb - Description of Parameterjava.io.IOException - Description of Exceptionpublic void write(byte[] b,
int pos,
int len)
throws java.io.IOException
write in interface java.io.DataOutputb - Description of Parameterpos - Description of Parameterlen - Description of Parameterjava.io.IOException - Description of Exceptionpublic void write(int b)
throws java.io.IOException
write in interface java.io.DataOutputb - Description of Parameterjava.io.IOException - Description of Exceptionpublic void flush()
throws java.io.IOException
java.io.IOException - Description of Exceptionpublic void close()
throws java.io.IOException
java.io.IOException - Description of Exceptionprotected int syncBuffer(long new_FP)
throws java.io.IOException
new_FP - Description of Parameterjava.io.IOException - Description of Exceptionprotected void fillBuffer()
throws java.io.IOException
java.io.IOException - Description of Exceptionprotected void commitBuffer()
throws java.io.IOException
java.io.IOException - Description of Exception