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 Closeable
close
in interface AutoCloseable
close
in interface FitsIO
IOException
public void flush() throws IOException
ArrayDataOutput
flush
in interface ArrayDataOutput
IOException
- 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 RandomAccess
public long length() throws IOException
IOException
- if the operation failedpublic void mark(int readlimit) throws IOException
ArrayDataInput
mark
method of
InputStream
.mark
in interface ArrayDataInput
readlimit
- 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
ArrayDataInput
read
in interface ArrayDataInput
b
- array of boolean's.IOException
- if one of the underlying read operations failedpublic int read(boolean[] b, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
b
- 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
ArrayDataInput
read
in interface ArrayDataInput
buf
- 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
ArrayDataInput
read
in interface ArrayDataInput
buf
- 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
ArrayDataInput
read
in interface ArrayDataInput
c
- array of char's.IOException
- if one of the underlying read operations failedpublic int read(char[] c, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
c
- 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
ArrayDataInput
read
in interface ArrayDataInput
d
- array of double's.IOException
- if one of the underlying read operations failedpublic int read(double[] d, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
d
- 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
ArrayDataInput
read
in interface ArrayDataInput
f
- array of float's.IOException
- if one of the underlying read operations failedpublic int read(float[] f, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
f
- 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
ArrayDataInput
read
in interface ArrayDataInput
i
- array of int's.IOException
- if one of the underlying read operations failedpublic int read(int[] i, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
i
- 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
ArrayDataInput
read
in interface ArrayDataInput
l
- array of long's.IOException
- if one of the underlying read operations failedpublic int read(long[] l, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
l
- 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
ArrayDataInput
read
in interface ArrayDataInput
s
- array of short's.IOException
- if one of the underlying read operations failedpublic int read(short[] s, int start, int length) throws IOException
ArrayDataInput
read
in interface ArrayDataInput
s
- 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
ArrayDataInput
The ArrayDataInput classes do not support String input since it is unclear how one would read in an Array of strings.
readArray
in interface ArrayDataInput
o
- A [multidimensional] primitive (or Object) array.IOException
- if the underlying stream failedpublic boolean readBoolean() throws IOException
readBoolean
in interface DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public char readChar() throws IOException
readChar
in interface DataInput
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
IOException
public void readFully(byte[] b, int off, int len) throws IOException
ArrayDataInput
readFully
in interface DataInput
readFully
in interface ArrayDataInput
b
- The input buffer.off
- The requested offset into the buffer.len
- The number of bytes requested.IOException
public int readInt() throws IOException
readInt
in interface DataInput
IOException
public long readLArray(Object o) throws IOException
ArrayDataInput
readLArray
in interface ArrayDataInput
o
- 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 DataInput
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public int readUnsignedByte() throws IOException
readUnsignedByte
in interface DataInput
IOException
public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public void reset() throws IOException
ArrayDataInput
reset
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 ArrayDataInput
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 IOException
RandomAccess
seek
in interface RandomAccess
offsetFromStart
- 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
ArrayDataInput
skip
in interface ArrayDataInput
offset
- the number of bytes to skipIOException
- if the underlying stream failedpublic void skipAllBytes(int toSkip) throws IOException
ArrayDataInput
skipAllBytes
in interface ArrayDataInput
toSkip
- the number of bytes to skipIOException
- if the underlying stream failedpublic void skipAllBytes(long toSkip) throws IOException
ArrayDataInput
skipAllBytes
in interface ArrayDataInput
toSkip
- the number of bytes to skipIOException
- if the underlying stream failedpublic int skipBytes(int n) throws IOException
skipBytes
in interface DataInput
IOException
public void write(boolean[] b) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
b
- array of boolean's.IOException
- if one of the underlying write operations failedpublic void write(boolean[] b, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
b
- 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 DataOutput
IOException
public void write(byte[] buf, int offset, int length) throws IOException
write
in interface DataOutput
IOException
public void write(char[] c) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
c
- array of char's.IOException
- if one of the underlying write operations failedpublic void write(char[] c, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
c
- 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
ArrayDataOutput
write
in interface ArrayDataOutput
d
- array of double's.IOException
- if one of the underlying write operations failedpublic void write(double[] d, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
d
- 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
ArrayDataOutput
write
in interface ArrayDataOutput
f
- array of float's.IOException
- if one of the underlying write operations failedpublic void write(float[] f, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
f
- 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 DataOutput
IOException
public void write(int[] i) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
i
- array of int'sIOException
- if one of the underlying write operations failedpublic void write(int[] i, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
i
- 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
ArrayDataOutput
write
in interface ArrayDataOutput
l
- array of longsIOException
- if one of the underlying write operations failedpublic void write(long[] l, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
l
- 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
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the value to writeIOException
- if one of the underlying write operations failedpublic void write(short[] s, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- 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
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the array to writeIOException
- if one of the underlying write operations failedpublic void write(String[] s, int start, int length) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- 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
ArrayDataOutput
writeArray
in interface ArrayDataOutput
o
- 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 DataOutput
IOException
public void writeByte(int b) throws IOException
writeByte
in interface DataOutput
IOException
public void writeBytes(String s) throws IOException
writeBytes
in interface DataOutput
IOException
public void writeChar(int c) throws IOException
writeChar
in interface DataOutput
IOException
public void writeChars(String s) throws IOException
writeChars
in interface DataOutput
IOException
public void writeDouble(double d) throws IOException
writeDouble
in interface DataOutput
IOException
public void writeFloat(float f) throws IOException
writeFloat
in interface DataOutput
IOException
public void writeInt(int i) throws IOException
writeInt
in interface DataOutput
IOException
public void writeLong(long l) throws IOException
writeLong
in interface DataOutput
IOException
public void writeShort(int s) throws IOException
writeShort
in interface DataOutput
IOException
public void writeUTF(String s) throws IOException
writeUTF
in interface DataOutput
IOException
Copyright © 1996–2016 nom-tam-fits. All rights reserved.