public class BufferedFile extends java.lang.Object implements ArrayDataOutput, RandomAccess
BITS_OF_1_BYTE, BITS_OF_2_BYTES, BITS_OF_3_BYTES, BITS_OF_4_BYTES, BITS_OF_5_BYTES, BITS_OF_6_BYTES, BITS_OF_7_BYTES, BYTE_1_OF_LONG_MASK, BYTE_2_OF_LONG_MASK, BYTE_3_OF_LONG_MASK, BYTE_4_OF_LONG_MASK, BYTE_MASK, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_FLOAT, BYTES_IN_INTEGER, BYTES_IN_LONG, BYTES_IN_SHORT, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK| 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
dataBuffer.buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
finalize() |
void |
flush()
Flush the output buffer
|
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.
|
long |
length() |
void |
mark(int readlimit)
See the general contract of the
mark method of
InputStream. |
int |
read() |
int |
read(boolean[] b)
Read an array of boolean's.
|
int |
read(boolean[] b,
int start,
int length)
Read a segment of an array of boolean's.
|
int |
read(byte[] buf)
Read an array of byte's.
|
int |
read(byte[] buf,
int offset,
int len)
Read a segment of an array of byte's.
|
int |
read(char[] c)
Read an array of char's.
|
int |
read(char[] c,
int start,
int length)
Read a segment of an array of char's.
|
int |
read(double[] d)
Read an array of double's.
|
int |
read(double[] d,
int start,
int length)
Read a segment of an array of double's.
|
int |
read(float[] f)
Read an array of float's.
|
int |
read(float[] f,
int start,
int length)
Read a segment of an array of float's.
|
int |
read(int[] i)
Read an array of int's.
|
int |
read(int[] i,
int start,
int length)
Read a segment of an array of int's.
|
int |
read(long[] l)
Read a segment of an array of long's.
|
int |
read(long[] l,
int start,
int length)
Read a segment of an array of long's.
|
int |
read(short[] s)
Read an array of short's.
|
int |
read(short[] s,
int start,
int length)
Read a segment of an array of short's.
|
int |
readArray(java.lang.Object o)
Deprecated.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len)
Read a buffer and signal an EOF if the requested elements cannot be read.
|
int |
readInt() |
long |
readLArray(java.lang.Object o)
Read an object.
|
java.lang.String |
readLine()
Read a line of input.
|
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF() |
void |
reset()
See the general contract of the
reset method of
InputStream. |
void |
seek(long offsetFromStart)
Move to a specified location in the stream.
|
void |
setLength(long newLength)
Set the length of the file.
|
long |
skip(long offset)
Skip the number of bytes.
|
void |
skipAllBytes(int toSkip)
Skip the number of bytes.
|
void |
skipAllBytes(long toSkip)
Skip the number of bytes.
|
int |
skipBytes(int n) |
void |
write(boolean[] b)
Write an array of boolean's.
|
void |
write(boolean[] b,
int start,
int length)
Write a segment of an array of boolean's.
|
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)
Write a segment of an array of char's.
|
void |
write(double[] d)
Write an array of double's.
|
void |
write(double[] d,
int start,
int length)
Write a segment of an array of double's.
|
void |
write(float[] f)
Write an array of float's.
|
void |
write(float[] f,
int start,
int length)
Write a segment of an array of float's.
|
void |
write(int buf) |
void |
write(int[] i)
Write an array of int's.
|
void |
write(int[] i,
int start,
int length)
Write a segment of an array of int's.
|
void |
write(long[] l)
Write an array of longs.
|
void |
write(long[] l,
int start,
int length)
Write a segment of an array of longs.
|
void |
write(short[] s)
Write an array of shorts.
|
void |
write(short[] s,
int start,
int length)
Write a segment of an array of shorts.
|
void |
write(java.lang.String[] s)
Write an array of Strings.
|
void |
write(java.lang.String[] s,
int start,
int length)
Write a segment of an array of Strings.
|
void |
writeArray(java.lang.Object o)
This routine provides efficient writing of arrays of any primitive type.
|
void |
writeBoolean(boolean b) |
void |
writeByte(int b) |
void |
writeBytes(java.lang.String s) |
void |
writeChar(int c) |
void |
writeChars(java.lang.String s) |
void |
writeDouble(double d) |
void |
writeFloat(float f) |
void |
writeInt(int i) |
void |
writeLong(long l) |
void |
writeShort(int s) |
void |
writeUTF(java.lang.String s) |
public BufferedFile(java.io.File file)
throws java.io.IOException
file - the file to open.java.io.IOException - if the file could not be openedpublic BufferedFile(java.io.File file,
java.lang.String mode)
throws java.io.IOException
file - the file to open.mode - the mode to open the file injava.io.IOException - if the file could not be openedpublic BufferedFile(java.io.File file,
java.lang.String mode,
int bufferSize)
throws java.io.IOException
file - the file to open.mode - the mode to open the file inbufferSize - the dataBuffer.buffer size to usejava.io.IOException - if the file could not be openedpublic BufferedFile(java.lang.String filename)
throws java.io.IOException
filename - the name of the file to openjava.io.IOException - if the file could not be openedpublic 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.IOException - if the file could not be openedpublic 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 dataBuffer.buffer size to be used. This should be
substantially larger than 100 bytes and defaults to 32768
bytes in the other constructors.java.io.IOException - if the file could not be openedpublic void close()
throws java.io.IOException
protected void finalize()
finalize in class java.lang.Objectpublic void flush()
throws java.io.IOException
ArrayDataOutputflush in interface ArrayDataOutputjava.io.IOException - if the flush of the underlying stream failedpublic java.nio.channels.FileChannel getChannel()
public java.io.FileDescriptor getFD()
throws java.io.IOException
java.io.IOException - if the descriptor could not be accessed.public long getFilePointer()
getFilePointer in interface RandomAccesspublic long length()
throws java.io.IOException
java.io.IOException - if the operation failedpublic void mark(int readlimit)
throws java.io.IOException
ArrayDataInputmark method of
InputStream.mark in interface ArrayDataInputreadlimit - the maximum limit of bytes that can be read before the mark
position becomes invalid.java.io.IOException - if the operation failedBufferedInputStream.reset()public int read()
throws java.io.IOException
java.io.IOException - if the underlying read operation failspublic int read(boolean[] b)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputb - array of boolean's.java.io.IOException - if one of the underlying read operations failedpublic int read(boolean[] b,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputb - array of boolean's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failedpublic int read(byte[] buf)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputbuf - array of byte's.java.io.IOException - if one of the underlying read operations failedDataInput.readFully(byte[])public int read(byte[] buf,
int offset,
int len)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputbuf - array of byte's.offset - start index in the arraylen - number of array elements to readjava.io.IOException - if one of the underlying read operations failedArrayDataInput.readFully(byte[], int, int)public int read(char[] c)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputc - array of char's.java.io.IOException - if one of the underlying read operations failedpublic int read(char[] c,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputc - array of char's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failedpublic int read(double[] d)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputd - array of double's.java.io.IOException - if one of the underlying read operations failedpublic int read(double[] d,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputd - array of double's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failedpublic int read(float[] f)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputf - array of float's.java.io.IOException - if one of the underlying read operations failedpublic int read(float[] f,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputf - array of float's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failedpublic int read(int[] i)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputi - array of int's.java.io.IOException - if one of the underlying read operations failedpublic int read(int[] i,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputi - array of int's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failedpublic int read(long[] l)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputl - array of long's.java.io.IOException - if one of the underlying read operations failedpublic int read(long[] l,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputl - array of long's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failedpublic int read(short[] s)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputs - array of short's.java.io.IOException - if one of the underlying read operations failedpublic int read(short[] s,
int start,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputs - array of short's.start - start index in the arraylength - number of array elements to readjava.io.IOException - if one of the underlying read operations failed@Deprecated
public int readArray(java.lang.Object o)
throws java.io.IOException
ArrayDataInputThe ArrayDataInput classes do not support String input since it is unclear how one would read in an Array of strings.
readArray in interface ArrayDataInputo - A [multidimensional] primitive (or Object) array.java.io.IOException - if the underlying stream failedpublic 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 char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
readFloat 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
ArrayDataInputreadFully in interface java.io.DataInputreadFully in interface ArrayDataInputb - The input buffer.off - The requested offset into the buffer.len - The number of bytes requested.java.io.IOExceptionpublic int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOExceptionpublic long readLArray(java.lang.Object o)
throws java.io.IOException
ArrayDataInputreadLArray in interface ArrayDataInputo - The object to be read. This object should be a primitive
(possibly multi-dimensional) array.java.io.IOException - if the underlying stream failedpublic java.lang.String readLine()
throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.IOExceptionpublic void reset()
throws java.io.IOException
ArrayDataInputreset method of
InputStream.
If markpos is -1 (no mark has been set or the
mark has been invalidated), an IOException is thrown.
Otherwise, pos is set equal to markpos.
reset in interface ArrayDataInputjava.io.IOException - if this stream has not been marked or, if the mark has
been invalidated, or the stream has been closed by
invoking its FitsIO.close() method, or an I/O error
occurs.BufferedInputStream.mark(int)public void seek(long offsetFromStart)
throws java.io.IOException
RandomAccessseek in interface RandomAccessoffsetFromStart - set the offset messured from the startjava.io.IOException - if the operation failspublic void setLength(long newLength)
throws java.io.IOException
newLength - The number of bytes at which the file is set.java.io.IOException - if the resizing of the underlying stream failspublic long skip(long offset)
throws java.io.IOException
ArrayDataInputskip in interface ArrayDataInputoffset - the number of bytes to skipjava.io.IOException - if the underlying stream failedpublic void skipAllBytes(int toSkip)
throws java.io.IOException
ArrayDataInputskipAllBytes in interface ArrayDataInputtoSkip - the number of bytes to skipjava.io.IOException - if the underlying stream failedpublic void skipAllBytes(long toSkip)
throws java.io.IOException
ArrayDataInputskipAllBytes in interface ArrayDataInputtoSkip - the number of bytes to skipjava.io.IOException - if the underlying stream failedpublic int skipBytes(int n)
throws java.io.IOException
skipBytes in interface java.io.DataInputjava.io.IOExceptionpublic void write(boolean[] b)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputb - array of boolean's.java.io.IOException - if one of the underlying write operations failedpublic void write(boolean[] b,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputb - array of boolean's.start - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(byte[] buf)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void write(byte[] buf,
int offset,
int length)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void write(char[] c)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputc - array of char's.java.io.IOException - if one of the underlying write operations failedpublic void write(char[] c,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputc - array of char's.start - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(double[] d)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputd - array of double's.java.io.IOException - if one of the underlying write operations failedpublic void write(double[] d,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputd - array of double's.start - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(float[] f)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputf - array of float's.java.io.IOException - if one of the underlying write operations failedpublic void write(float[] f,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputf - array of float's.start - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(int buf)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void write(int[] i)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputi - array of int'sjava.io.IOException - if one of the underlying write operations failedpublic void write(int[] i,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputi - array of int'sstart - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(long[] l)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputl - array of longsjava.io.IOException - if one of the underlying write operations failedpublic void write(long[] l,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputl - array of longsstart - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(short[] s)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the value to writejava.io.IOException - if one of the underlying write operations failedpublic void write(short[] s,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the value to writestart - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void write(java.lang.String[] s)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the array to writejava.io.IOException - if one of the underlying write operations failedpublic void write(java.lang.String[] s,
int start,
int length)
throws java.io.IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the array to writestart - start index in the arraylength - number of array elements to writejava.io.IOException - if one of the underlying write operations failedpublic void writeArray(java.lang.Object o)
throws java.io.IOException
ArrayDataOutputwriteArray in interface ArrayDataOutputo - The object to be written. It must be an array of a primitive
type, Object, or String.java.io.IOException - if one of the underlying write operations failedpublic void writeBoolean(boolean b)
throws java.io.IOException
writeBoolean in interface java.io.DataOutputjava.io.IOExceptionpublic void writeByte(int b)
throws java.io.IOException
writeByte in interface java.io.DataOutputjava.io.IOExceptionpublic void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputjava.io.IOExceptionpublic void writeChar(int c)
throws java.io.IOException
writeChar in interface java.io.DataOutputjava.io.IOExceptionpublic void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface java.io.DataOutputjava.io.IOExceptionpublic void writeDouble(double d)
throws java.io.IOException
writeDouble in interface java.io.DataOutputjava.io.IOExceptionpublic void writeFloat(float f)
throws java.io.IOException
writeFloat in interface java.io.DataOutputjava.io.IOExceptionpublic void writeInt(int i)
throws java.io.IOException
writeInt in interface java.io.DataOutputjava.io.IOExceptionpublic void writeLong(long l)
throws java.io.IOException
writeLong in interface java.io.DataOutputjava.io.IOExceptionpublic void writeShort(int s)
throws java.io.IOException
writeShort in interface java.io.DataOutputjava.io.IOExceptionpublic void writeUTF(java.lang.String s)
throws java.io.IOException
writeUTF in interface java.io.DataOutputjava.io.IOException