public class BufferedDataInputStream extends java.io.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.
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, DEFAULT_BUFFER_SIZE, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK| Constructor and Description |
|---|
BufferedDataInputStream(java.io.InputStream o)
Create a BufferedInputStream based on an input stream.
|
BufferedDataInputStream(java.io.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(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()
Deprecated.
Use
BufferedReader methods. |
long |
readLong() |
int |
readPrimitiveArray(java.lang.Object o)
Deprecated.
use
readLArray(Object) instead |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF() |
void |
skipAllBytes(int toSkip)
Skip the number of bytes.
|
void |
skipAllBytes(long toSkip)
Skip the number of bytes.
|
int |
skipBytes(int toSkip) |
java.lang.String |
toString() |
available, close, mark, markSupported, read, reset, skipclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitmark, read, reset, skippublic BufferedDataInputStream(java.io.InputStream o)
o - the input stream to use for reading.public BufferedDataInputStream(java.io.InputStream o,
int bufLength)
o - the input stream to use for reading.bufLength - the buffer length to use.public 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[] obuf,
int offset,
int length)
throws java.io.IOException
ArrayDataInputread in interface ArrayDataInputread in class java.io.BufferedInputStreamobuf - array of byte's.offset - start index in the arraylength - 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 failed@Deprecated
public java.lang.String readLine()
throws java.io.IOException
BufferedReader methods.readLine in interface java.io.DataInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOException@Deprecated
public int readPrimitiveArray(java.lang.Object o)
throws java.io.IOException
readLArray(Object) insteado - The object to be read. It must be an array of a primitive
type, or an array of Object's.java.io.IOException - if the underlying read operation failspublic 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 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 toSkip)
throws java.io.IOException
skipBytes in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object