public class BufferedFile extends java.lang.Object implements ArrayDataInput, ArrayDataOutput, RandomAccess
| Constructor and Description |
|---|
BufferedFile(java.io.File file)
Create a buffered file from a File descriptor
|
BufferedFile(java.io.File file,
java.lang.String mode)
Create a buffered file from a File descriptor
|
BufferedFile(java.io.File file,
java.lang.String mode,
int bufferSize)
Create a buffered file from a file descriptor
|
BufferedFile(java.lang.String filename)
Create a read-only buffered file
|
BufferedFile(java.lang.String filename,
java.lang.String mode)
Create a buffered file with the given mode.
|
BufferedFile(java.lang.String filename,
java.lang.String mode,
int bufferSize)
Create a buffered file with the given mode and a specified
buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the file
|
protected void |
finalize()
Clear up any pending output at cleanup.
|
void |
flush()
Flush output buffer if necessary.
|
java.nio.channels.FileChannel |
getChannel()
Get the channel associated with
this file.
|
java.io.FileDescriptor |
getFD()
Get the file descriptor associated with
this stream.
|
long |
getFilePointer()
Get the current offset into the file.
|
protected void |
initialize(java.io.File file,
java.lang.String mode,
int bufferSize) |
long |
length()
Get the current length of the file.
|
protected long |
primitiveArrayRecurse(java.lang.Object o) |
int |
read()
Read a byte
|
int |
read(boolean[] b) |
int |
read(boolean[] b,
int start,
int length) |
int |
read(byte[] buf)
Create a buffered file using a mapped
/** Read an entire byte array.
|
int |
read(byte[] buf,
int offset,
int len)
Read into a segment of a byte array.
|
int |
read(char[] c) |
int |
read(char[] c,
int start,
int length) |
int |
read(double[] d) |
int |
read(double[] d,
int start,
int length) |
int |
read(float[] f) |
int |
read(float[] f,
int start,
int length) |
int |
read(int[] i) |
int |
read(int[] i,
int start,
int length) |
int |
read(long[] l) |
int |
read(long[] l,
int start,
int length) |
int |
read(short[] s) |
int |
read(short[] s,
int start,
int length) |
int |
readArray(java.lang.Object o)
Deprecated.
The readLArray(Object) routine should be used to
ensure that large arrays which read more than
two-gigabytes return the proper value.
|
boolean |
readBoolean()
Read a boolean
|
byte |
readByte()
Read a byte
|
char |
readChar()
Read a char
|
double |
readDouble()
Read a double.
|
float |
readFloat()
Read a float.
|
void |
readFully(byte[] b)
Read a byte array fully.
|
void |
readFully(byte[] b,
int off,
int len)
Read a byte array fully.
|
int |
readInt()
Read an int
|
long |
readLArray(java.lang.Object o)
This routine provides efficient reading of arrays of any primitive
type.
|
java.lang.String |
readLine()
Read a line of input.
|
long |
readLong()
Read a long.
|
short |
readShort()
Read a short
|
int |
readUnsignedByte()
Read an unsigned byte.
|
int |
readUnsignedShort()
Read an unsigned short.
|
java.lang.String |
readUTF()
Read a string encoded as a UTF.
|
void |
seek(long offsetFromStart)
Move to the current offset from the beginning of the file.
|
void |
setLength(long newLength)
Set the length of the file.
|
long |
skip(long offset)
Skip from the current position.
|
int |
skipBytes(int toSkip)
Skip the number of bytes.
|
long |
skipBytes(long toSkip) |
void |
write(boolean[] b)
Write an array of booleans.
|
void |
write(boolean[] b,
int start,
int length) |
void |
write(byte[] buf) |
void |
write(byte[] buf,
int offset,
int length) |
void |
write(char[] c)
Write an array of char's.
|
void |
write(char[] c,
int start,
int length) |
void |
write(double[] d)
Write an array of doubles.
|
void |
write(double[] d,
int start,
int length) |
void |
write(float[] f)
Write an array of floats.
|
void |
write(float[] f,
int start,
int length) |
void |
write(int buf) |
void |
write(int[] i)
Write an array of int's.
|
void |
write(int[] i,
int start,
int length) |
void |
write(long[] l)
Write an array of longs.
|
void |
write(long[] l,
int start,
int length) |
void |
write(short[] s)
Write an array of shorts.
|
void |
write(short[] s,
int start,
int length) |
void |
write(java.lang.String[] s)
Write an array of Strings -- equivalent to calling writeBytes for each string.
|
void |
write(java.lang.String[] s,
int start,
int length) |
void |
writeArray(java.lang.Object o)
This routine provides efficient writing of arrays of any primitive type.
|
void |
writeBoolean(boolean b)
Write a boolean value
|
void |
writeByte(int b)
Write a byte value.
|
void |
writeBytes(java.lang.String s)
Write a string using the local protocol to convert char's to bytes.
|
void |
writeChar(int c)
Write a char value.
|
void |
writeChars(java.lang.String s)
Write a string as an array of chars.
|
void |
writeDouble(double d)
Write a double value.
|
void |
writeFloat(float f)
Write a float value.
|
void |
writeInt(int i)
Write an integer value.
|
void |
writeLong(long l)
Write a long value.
|
void |
writeShort(int s)
Write a short value.
|
void |
writeUTF(java.lang.String s)
Write a string as a UTF.
|
public BufferedFile(java.lang.String filename)
throws java.io.IOException
java.io.IOExceptionpublic BufferedFile(java.lang.String filename,
java.lang.String mode)
throws java.io.IOException
filename - The file to be accessed.mode - A string composed of "r" and "w" for
read and write access.java.io.IOExceptionpublic BufferedFile(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic BufferedFile(java.io.File file,
java.lang.String mode)
throws java.io.IOException
java.io.IOExceptionpublic BufferedFile(java.lang.String filename,
java.lang.String mode,
int bufferSize)
throws java.io.IOException
filename - The file to be accessed.mode - A string composed of "r" and "w" indicating
read or write access.bufferSize - The buffer size to be used. This should be
substantially larger than 100 bytes and
defaults to 32768 bytes in the other
constructors.java.io.IOExceptionpublic BufferedFile(java.io.File file,
java.lang.String mode,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionprotected void initialize(java.io.File file,
java.lang.String mode,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic int read(byte[] buf)
throws java.io.IOException
read in interface ArrayDataInputbuf - The array to be filled.java.io.IOExceptionpublic int read(byte[] buf,
int offset,
int len)
throws java.io.IOException
read in interface ArrayDataInputbuf - The array to be filled.offset - The starting location for input.len - The number of bytes to be read. Fewer bytes
will be read if an EOF is reached.java.io.IOExceptionpublic int read()
throws java.io.IOException
java.io.IOExceptionpublic long skip(long offset)
throws java.io.IOException
skip in interface ArrayDataInputoffset - The number of bytes from the
current position. This may
be negative.java.io.IOExceptionpublic void seek(long offsetFromStart)
throws java.io.IOException
seek in interface RandomAccessjava.io.IOExceptionpublic boolean readBoolean()
throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOExceptionpublic byte readByte()
throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOExceptionpublic short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOExceptionpublic void readFully(byte[] b)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic int skipBytes(int toSkip)
throws java.io.IOException
skipBytes in interface java.io.DataInputjava.io.IOExceptionpublic long skipBytes(long toSkip)
throws java.io.IOException
skipBytes in interface ArrayDataInputjava.io.IOExceptionpublic java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readLine()
throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOExceptionpublic int readArray(java.lang.Object o)
throws java.io.IOException
readArray in interface ArrayDataInputo - The object to be read. It must be an array of a primitive type,
or an array of Object's.java.io.IOExceptionpublic long readLArray(java.lang.Object o)
throws java.io.IOException
readLArray in interface ArrayDataInputo - The object to be read. It must be an arraof of a primtive type
(or any dimension), or an array of Objects which contains
pointers to primitive arrays or other object arrays.java.io.IOExceptionprotected long primitiveArrayRecurse(java.lang.Object o)
throws java.io.IOException
java.io.IOExceptionpublic int read(boolean[] b)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(boolean[] b,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(short[] s)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(short[] s,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(char[] c)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(char[] c,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(int[] i)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(int[] i,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(long[] l)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(long[] l,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(float[] f)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(float[] f,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(double[] d)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic int read(double[] d,
int start,
int length)
throws java.io.IOException
read in interface ArrayDataInputjava.io.IOExceptionpublic void write(int buf)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void write(byte[] buf)
throws java.io.IOException
write in interface java.io.DataOutputwrite in interface ArrayDataOutputjava.io.IOExceptionpublic void write(byte[] buf,
int offset,
int length)
throws java.io.IOException
write in interface java.io.DataOutputwrite in interface ArrayDataOutputjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface ArrayDataOutputjava.io.IOExceptionprotected void finalize()
finalize in class java.lang.Objectpublic void writeBoolean(boolean b)
throws java.io.IOException
writeBoolean in interface java.io.DataOutputb - The value to be written. Externally true is represented as
a byte of 1 and false as a byte value of 0.java.io.IOExceptionpublic void writeByte(int b)
throws java.io.IOException
writeByte in interface java.io.DataOutputjava.io.IOExceptionpublic void writeInt(int i)
throws java.io.IOException
writeInt in interface java.io.DataOutputjava.io.IOExceptionpublic void writeShort(int s)
throws java.io.IOException
writeShort in interface java.io.DataOutputjava.io.IOExceptionpublic void writeChar(int c)
throws java.io.IOException
writeChar in interface java.io.DataOutputjava.io.IOExceptionpublic void writeLong(long l)
throws java.io.IOException
writeLong in interface java.io.DataOutputjava.io.IOExceptionpublic void writeFloat(float f)
throws java.io.IOException
writeFloat in interface java.io.DataOutputjava.io.IOExceptionpublic void writeDouble(double d)
throws java.io.IOException
writeDouble in interface java.io.DataOutputjava.io.IOExceptionpublic void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputs - The string to be written.java.io.IOExceptionpublic void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface java.io.DataOutputjava.io.IOExceptionpublic void writeUTF(java.lang.String s)
throws java.io.IOException
writeUTF in interface java.io.DataOutputjava.io.IOExceptionpublic void writeArray(java.lang.Object o)
throws java.io.IOException
writeArray in interface ArrayDataOutputo - The object to be written. It must be an array of a primitive
type, Object, or String.java.io.IOException - if the argument is not of the proper typepublic void write(boolean[] b)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(boolean[] b,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(short[] s)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(short[] s,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(char[] c)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(char[] c,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(int[] i)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(int[] i,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(long[] l)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(long[] l,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(float[] f)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(float[] f,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(double[] d)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(double[] d,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(java.lang.String[] s)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void write(java.lang.String[] s,
int start,
int length)
throws java.io.IOException
write in interface ArrayDataOutputjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface ArrayDataInputclose in interface ArrayDataOutputjava.io.IOExceptionpublic java.io.FileDescriptor getFD()
throws java.io.IOException
java.io.IOExceptionpublic java.nio.channels.FileChannel getChannel()
public long length()
throws java.io.IOException
java.io.IOExceptionpublic long getFilePointer()
getFilePointer in interface RandomAccesspublic void setLength(long newLength)
throws java.io.IOException
newLength - The number of bytes at which the file
is set.java.io.IOException