public class BufferedFile extends 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(File file)
Create a buffered file from a File descriptor
|
BufferedFile(File file,
String mode)
Create a buffered file from a File descriptor
|
BufferedFile(File file,
String mode,
int bufferSize)
Create a buffered file from a file descriptor
|
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
dataBuffer.buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
finalize() |
void |
flush()
Flush the output buffer
|
FileChannel |
getChannel()
Get the channel associated with this file.
|
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(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(Object o)
Read an object.
|
String |
readLine()
Read a line of input.
|
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
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(String[] s)
Write an array of Strings.
|
void |
write(String[] s,
int start,
int length)
Write a segment of an array of Strings.
|
void |
writeArray(Object o)
This routine provides efficient writing of arrays of any primitive type.
|
void |
writeBoolean(boolean b) |
void |
writeByte(int b) |
void |
writeBytes(String s) |
void |
writeChar(int c) |
void |
writeChars(String s) |
void |
writeDouble(double d) |
void |
writeFloat(float f) |
void |
writeInt(int i) |
void |
writeLong(long l) |
void |
writeShort(int s) |
void |
writeUTF(String s) |
public BufferedFile(File file) throws IOException
file - the file to open.IOException - if the file could not be openedpublic BufferedFile(File file, String mode) throws IOException
file - the file to open.mode - the mode to open the file inIOException - if the file could not be openedpublic BufferedFile(File file, String mode, int bufferSize) throws IOException
file - the file to open.mode - the mode to open the file inbufferSize - the dataBuffer.buffer size to useIOException - if the file could not be openedpublic BufferedFile(String filename) throws IOException
filename - the name of the file to openIOException - if the file could not be openedpublic 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.IOException - if the file could not be openedpublic 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.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.IOException - if the file could not be openedpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface FitsIOIOExceptionpublic void flush()
throws IOException
ArrayDataOutputflush in interface ArrayDataOutputIOException - if the flush of the underlying stream failedpublic FileChannel getChannel()
public FileDescriptor getFD() throws IOException
IOException - if the descriptor could not be accessed.public long getFilePointer()
getFilePointer in interface RandomAccesspublic long length()
throws IOException
IOException - if the operation failedpublic void mark(int readlimit)
throws IOException
ArrayDataInputmark method of
InputStream.mark in interface ArrayDataInputreadlimit - the maximum limit of bytes that can be read before the mark
position becomes invalid.IOException - if the operation failedBufferedInputStream.reset()public int read()
throws IOException
IOException - if the underlying read operation failspublic int read(boolean[] b)
throws IOException
ArrayDataInputread in interface ArrayDataInputb - array of boolean's.IOException - if one of the underlying read operations failedpublic int read(boolean[] b,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputb - array of boolean's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failedpublic int read(byte[] buf)
throws IOException
ArrayDataInputread in interface ArrayDataInputbuf - array of byte's.IOException - if one of the underlying read operations failedDataInput.readFully(byte[])public int read(byte[] buf,
int offset,
int len)
throws IOException
ArrayDataInputread in interface ArrayDataInputbuf - array of byte's.offset - start index in the arraylen - number of array elements to readIOException - if one of the underlying read operations failedArrayDataInput.readFully(byte[], int, int)public int read(char[] c)
throws IOException
ArrayDataInputread in interface ArrayDataInputc - array of char's.IOException - if one of the underlying read operations failedpublic int read(char[] c,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputc - array of char's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failedpublic int read(double[] d)
throws IOException
ArrayDataInputread in interface ArrayDataInputd - array of double's.IOException - if one of the underlying read operations failedpublic int read(double[] d,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputd - array of double's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failedpublic int read(float[] f)
throws IOException
ArrayDataInputread in interface ArrayDataInputf - array of float's.IOException - if one of the underlying read operations failedpublic int read(float[] f,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputf - array of float's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failedpublic int read(int[] i)
throws IOException
ArrayDataInputread in interface ArrayDataInputi - array of int's.IOException - if one of the underlying read operations failedpublic int read(int[] i,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputi - array of int's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failedpublic int read(long[] l)
throws IOException
ArrayDataInputread in interface ArrayDataInputl - array of long's.IOException - if one of the underlying read operations failedpublic int read(long[] l,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputl - array of long's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failedpublic int read(short[] s)
throws IOException
ArrayDataInputread in interface ArrayDataInputs - array of short's.IOException - if one of the underlying read operations failedpublic int read(short[] s,
int start,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputs - array of short's.start - start index in the arraylength - number of array elements to readIOException - if one of the underlying read operations failed@Deprecated public int readArray(Object o) throws 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.IOException - if the underlying stream failedpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
ArrayDataInputreadFully in interface DataInputreadFully in interface ArrayDataInputb - The input buffer.off - The requested offset into the buffer.len - The number of bytes requested.IOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic long readLArray(Object o) throws IOException
ArrayDataInputreadLArray in interface ArrayDataInputo - The object to be read. This object should be a primitive
(possibly multi-dimensional) array.IOException - if the underlying stream failedpublic String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic void reset()
throws 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 ArrayDataInputIOException - 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 IOException
RandomAccessseek in interface RandomAccessoffsetFromStart - set the offset messured from the startIOException - if the operation failspublic void setLength(long newLength)
throws IOException
newLength - The number of bytes at which the file is set.IOException - if the resizing of the underlying stream failspublic long skip(long offset)
throws IOException
ArrayDataInputskip in interface ArrayDataInputoffset - the number of bytes to skipIOException - if the underlying stream failedpublic void skipAllBytes(int toSkip)
throws IOException
ArrayDataInputskipAllBytes in interface ArrayDataInputtoSkip - the number of bytes to skipIOException - if the underlying stream failedpublic void skipAllBytes(long toSkip)
throws IOException
ArrayDataInputskipAllBytes in interface ArrayDataInputtoSkip - the number of bytes to skipIOException - if the underlying stream failedpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputIOExceptionpublic void write(boolean[] b)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputb - array of boolean's.IOException - if one of the underlying write operations failedpublic void write(boolean[] b,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputb - array of boolean's.start - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(byte[] buf)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] buf,
int offset,
int length)
throws IOException
write in interface DataOutputIOExceptionpublic void write(char[] c)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputc - array of char's.IOException - if one of the underlying write operations failedpublic void write(char[] c,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputc - array of char's.start - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(double[] d)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputd - array of double's.IOException - if one of the underlying write operations failedpublic void write(double[] d,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputd - array of double's.start - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(float[] f)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputf - array of float's.IOException - if one of the underlying write operations failedpublic void write(float[] f,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputf - array of float's.start - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(int buf)
throws IOException
write in interface DataOutputIOExceptionpublic void write(int[] i)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputi - array of int'sIOException - if one of the underlying write operations failedpublic void write(int[] i,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputi - array of int'sstart - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(long[] l)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputl - array of longsIOException - if one of the underlying write operations failedpublic void write(long[] l,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputl - array of longsstart - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(short[] s)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the value to writeIOException - if one of the underlying write operations failedpublic void write(short[] s,
int start,
int length)
throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the value to writestart - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void write(String[] s) throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the array to writeIOException - if one of the underlying write operations failedpublic void write(String[] s, int start, int length) throws IOException
ArrayDataOutputwrite in interface ArrayDataOutputs - the array to writestart - start index in the arraylength - number of array elements to writeIOException - if one of the underlying write operations failedpublic void writeArray(Object o) throws IOException
ArrayDataOutputwriteArray in interface ArrayDataOutputo - The object to be written. It must be an array of a primitive
type, Object, or String.IOException - if one of the underlying write operations failedpublic void writeBoolean(boolean b)
throws IOException
writeBoolean in interface DataOutputIOExceptionpublic void writeByte(int b)
throws IOException
writeByte in interface DataOutputIOExceptionpublic void writeBytes(String s) throws IOException
writeBytes in interface DataOutputIOExceptionpublic void writeChar(int c)
throws IOException
writeChar in interface DataOutputIOExceptionpublic void writeChars(String s) throws IOException
writeChars in interface DataOutputIOExceptionpublic void writeDouble(double d)
throws IOException
writeDouble in interface DataOutputIOExceptionpublic void writeFloat(float f)
throws IOException
writeFloat in interface DataOutputIOExceptionpublic void writeInt(int i)
throws IOException
writeInt in interface DataOutputIOExceptionpublic void writeLong(long l)
throws IOException
writeLong in interface DataOutputIOExceptionpublic void writeShort(int s)
throws IOException
writeShort in interface DataOutputIOExceptionpublic void writeUTF(String s) throws IOException
writeUTF in interface DataOutputIOExceptionCopyright © 1996–2016 nom-tam-fits. All rights reserved.