public class BufferedFile extends Object implements ArrayDataInput, ArrayDataOutput, RandomAccess
| Constructor and Description |
|---|
BufferedFile(String filename)
Create a read-only buffered file
|
BufferedFile(String filename,
String mode)
Create a buffered file with the given mode.
|
BufferedFile(String filename,
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
|
void |
flush()
Flush output buffer if necessary.
|
FileChannel |
getChannel()
Return the FileChannel associated with the file.
|
FileDescriptor |
getFD()
Get the file descriptor associated with
this stream.
|
long |
getFilePointer()
Get the current offset into the file.
|
long |
length()
Get the current length of the file.
|
protected int |
primitiveArrayRecurse(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(Object o)
This routine provides efficient reading of arrays of any primitive type.
|
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
|
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.
|
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.
|
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(String[] s)
Write an array of Strings -- equivalent to calling writeBytes for each string.
|
void |
write(String[] s,
int start,
int length) |
void |
writeArray(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(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(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(String s)
Write a string as a UTF.
|
public BufferedFile(String filename) throws IOException
IOExceptionpublic BufferedFile(String filename, String mode) throws IOException
filename - The file to be accessed.mode - A string composed of "r" and "w" for
read and write access.IOExceptionpublic BufferedFile(String filename, String mode, int bufferSize) throws IOException
filename - The file to be accessed.mode - A string composed of "r" and "w" indicating
read or write access.buffer - The buffer size to be used. This should be
substantially larger than 100 bytes and
defaults to 32768 bytes in the other
constructors.IOExceptionpublic int read(byte[] buf)
throws IOException
read in interface ArrayDataInputbuf - The array to be filled.IOExceptionpublic int read(byte[] buf,
int offset,
int len)
throws IOException
read in interface ArrayDataInputbuf - The array to be filled.offset - The starting location for input.length - The number of bytes to be read. Fewer bytes
will be read if an EOF is reached.IOExceptionpublic int read()
throws IOException
IOExceptionpublic long skip(long offset)
throws IOException
skip in interface ArrayDataInputoffset - The number of bytes from the
current position. This may
be negative.IOExceptionpublic void seek(long offsetFromStart)
throws IOException
seek in interface RandomAccessIOExceptionpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionpublic int skipBytes(int toSkip)
throws IOException
skipBytes in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic int readArray(Object o) throws 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.IOExceptionprotected int primitiveArrayRecurse(Object o) throws IOException
IOExceptionpublic int read(boolean[] b)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(boolean[] b,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(short[] s)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(short[] s,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(char[] c)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(char[] c,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(int[] i)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(int[] i,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(long[] l)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(long[] l,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(float[] f)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(float[] f,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(double[] d)
throws IOException
read in interface ArrayDataInputIOExceptionpublic int read(double[] d,
int start,
int length)
throws IOException
read in interface ArrayDataInputIOExceptionpublic void write(int buf)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] buf)
throws IOException
write in interface DataOutputwrite in interface ArrayDataOutputIOExceptionpublic void write(byte[] buf,
int offset,
int length)
throws IOException
write in interface DataOutputwrite in interface ArrayDataOutputIOExceptionpublic void flush()
throws IOException
flush in interface ArrayDataOutputIOExceptionpublic void writeBoolean(boolean b)
throws IOException
writeBoolean in interface DataOutputb - The value to be written. Externally true is represented as
a byte of 1 and false as a byte value of 0.IOExceptionpublic void writeByte(int b)
throws IOException
writeByte in interface DataOutputIOExceptionpublic void writeInt(int i)
throws IOException
writeInt in interface DataOutputIOExceptionpublic void writeShort(int s)
throws IOException
writeShort in interface DataOutputIOExceptionpublic void writeChar(int c)
throws IOException
writeChar in interface DataOutputIOExceptionpublic void writeLong(long l)
throws IOException
writeLong in interface DataOutputIOExceptionpublic void writeFloat(float f)
throws IOException
writeFloat in interface DataOutputIOExceptionpublic void writeDouble(double d)
throws IOException
writeDouble in interface DataOutputIOExceptionpublic void writeBytes(String s) throws IOException
writeBytes in interface DataOutputs - The string to be written.IOExceptionpublic void writeChars(String s) throws IOException
writeChars in interface DataOutputIOExceptionpublic void writeUTF(String s) throws IOException
writeUTF in interface DataOutputIOExceptionpublic void writeArray(Object o) throws IOException
writeArray in interface ArrayDataOutputo - The object to be written. It must be an array of a primitive
type, Object, or String.IOException - if the argument is not of the proper typepublic void write(boolean[] b)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(boolean[] b,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(short[] s)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(short[] s,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(char[] c)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(char[] c,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(int[] i)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(int[] i,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(long[] l)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(long[] l,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(float[] f)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(float[] f,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(double[] d)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(double[] d,
int start,
int length)
throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(String[] s) throws IOException
write in interface ArrayDataOutputIOExceptionpublic void write(String[] s, int start, int length) throws IOException
write in interface ArrayDataOutputIOExceptionpublic void close()
throws IOException
close in interface ArrayDataInputclose in interface ArrayDataOutputIOExceptionpublic FileDescriptor getFD() throws IOException
IOExceptionpublic FileChannel getChannel()
public long length()
throws IOException
IOExceptionpublic long getFilePointer()
getFilePointer in interface RandomAccesspublic void setLength(long newLength)
throws IOException
newLength - The number of bytes at which the file
is set.IOExceptionCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.