public class BufferedDataInputStream extends BufferedInputStream implements ArrayDataInput
Many new read calls are added to allow efficient reading off array data. The read(Object o) call provides for reading a primitive array of arbitrary type or dimensionality. There are also reads for each type of one dimensional array.
Note that there is substantial duplication of code to minimize method invocations. E.g., the floating point read routines read the data as integer values and then convert to float. However the integer code is duplicated rather than invoked. There has been considerable effort expended to ensure that these routines are efficient, but they could easily be superceded if an efficient underlying I/O package were ever delivered as part of the basic Java libraries. [This has subsequently happened with the NIO package and in an ideal universe these classes would be rewritten to take advantage of NIO.]
Testing and timing routines are provided in the nom.tam.util.test.BufferedFileTester class. Version 1.1: October 12, 2000: Fixed handling of EOF to return partially read arrays when EOF is detected. Version 1.2: July 20, 2009: Added handling of very large Object arrays. Additional work is required to handle very large arrays generally.
inBITS_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, DEFAULT_BUFFER_SIZE, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK| Constructor and Description |
|---|
BufferedDataInputStream(InputStream o)
Create a BufferedInputStream based on an input stream.
|
BufferedDataInputStream(InputStream o,
int bufLength)
Create a BufferedInputStream based on a input stream with a specified
buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
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[] obuf,
int offset,
int length)
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()
Deprecated.
Use
BufferedReader methods. |
long |
readLong() |
int |
readPrimitiveArray(Object o)
Deprecated.
use
readLArray(Object) instead |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
void |
skipAllBytes(int toSkip)
Skip the number of bytes.
|
void |
skipAllBytes(long toSkip)
Skip the number of bytes.
|
int |
skipBytes(int toSkip) |
String |
toString() |
available, close, mark, markSupported, read, reset, skipreadclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitmark, read, reset, skippublic BufferedDataInputStream(InputStream o)
o - the input stream to use for reading.public BufferedDataInputStream(InputStream o, int bufLength)
o - the input stream to use for reading.bufLength - the buffer length to use.public 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[] obuf,
int offset,
int length)
throws IOException
ArrayDataInputread in interface ArrayDataInputread in class BufferedInputStreamobuf - array of byte's.offset - start index in the arraylength - 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 failed@Deprecated public String readLine() throws IOException
BufferedReader methods.readLine in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOException@Deprecated public int readPrimitiveArray(Object o) throws IOException
readLArray(Object) insteado - The object to be read. It must be an array of a primitive
type, or an array of Object's.IOException - if the underlying read operation failspublic 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 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 toSkip)
throws IOException
skipBytes in interface DataInputIOExceptionCopyright © 1996–2016 nom-tam-fits. All rights reserved.