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.
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.
in
Constructor and Description |
---|
BufferedDataInputStream(InputStream o)
Use the BufferedInputStream constructor
|
BufferedDataInputStream(InputStream o,
int bufLength)
Use the BufferedInputStream constructor
|
Modifier and Type | Method and Description |
---|---|
protected int |
primitiveArrayRecurse(Object o)
Read recursively over a multi-dimensional array.
|
int |
read(boolean[] b)
Read a boolean array
|
int |
read(boolean[] b,
int start,
int len)
Read a boolean array.
|
int |
read(byte[] obuf,
int offset,
int len)
Read a byte array.
|
int |
read(char[] c)
Read a character array
|
int |
read(char[] c,
int start,
int len)
Read a character array
|
int |
read(double[] d)
Read a double array
|
int |
read(double[] d,
int start,
int len)
Read a double array
|
int |
read(float[] f)
Read a float array
|
int |
read(float[] f,
int start,
int len)
Read a float array
|
int |
read(int[] i)
Read an integer array
|
int |
read(int[] i,
int start,
int len)
Read an integer array
|
int |
read(long[] l)
Read a long array
|
int |
read(long[] l,
int start,
int len)
Read a long array
|
int |
read(short[] s)
Read a short array
|
int |
read(short[] s,
int start,
int len)
Read a short array
|
int |
readArray(Object o)
Read an object.
|
boolean |
readBoolean()
Read a boolean value.
|
byte |
readByte()
Read a byte value in the range -128 to 127.
|
char |
readChar()
Read a 2-byte value as a character.
|
double |
readDouble()
Read an 8 byte real number.
|
float |
readFloat()
Read a 4 byte real number.
|
void |
readFully(byte[] b)
Read a buffer and signal an EOF if the buffer
cannot be fully read.
|
void |
readFully(byte[] b,
int off,
int len)
Read a buffer and signal an EOF if the requested elements
cannot be read.
|
int |
readInt()
Read an integer.
|
String |
readLine()
Deprecated.
Use BufferedReader methods.
|
long |
readLong()
Read a long.
|
int |
readPrimitiveArray(Object o)
Deprecated.
See readArray(Object o).
|
short |
readShort()
Read a 2-byte value as a short (-32788 to 32767)
|
int |
readUnsignedByte()
Read a byte value in the range 0-255.
|
int |
readUnsignedShort()
Read a 2-byte value in the range 0-65536.
|
String |
readUTF()
Read a String in the UTF format.
|
int |
skipBytes(int toSkip)
Skip the requested number of bytes.
|
String |
toString()
Represent the stream as a string
|
available, close, mark, markSupported, read, reset, skip
read
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, read, skip
public BufferedDataInputStream(InputStream o)
public BufferedDataInputStream(InputStream o, int bufLength)
public int read(byte[] obuf, int offset, int len) throws IOException
read
in interface ArrayDataInput
read
in class BufferedInputStream
obuf
- The byte array.offset
- The starting offset into the array.len
- The number of bytes to read.IOException
public boolean readBoolean() throws IOException
readBoolean
in interface DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public int readUnsignedByte() throws IOException
readUnsignedByte
in interface DataInput
IOException
public int readInt() throws IOException
readInt
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
public char readChar() throws IOException
readChar
in interface DataInput
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
b
- The buffer to be read.IOException
public void readFully(byte[] b, int off, int len) throws IOException
readFully
in interface DataInput
b
- The input buffer.off
- The requested offset into the buffer.len
- The number of bytes requested.IOException
public int skipBytes(int toSkip) throws IOException
skipBytes
in interface DataInput
toSkip
- The number of bytes to skip.IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public String readLine() throws IOException
readLine
in interface DataInput
IOException
public int readPrimitiveArray(Object o) throws IOException
o
- The object to be read. It must be an array of a primitive type,
or an array of Object's.IOException
public int readArray(Object o) throws IOException
readArray
in interface ArrayDataInput
o
- The object to be read. This object should
be a primitive (possibly multi-dimensional) array.IOException
protected int primitiveArrayRecurse(Object o) throws IOException
IOException
public int read(boolean[] b) throws IOException
read
in interface ArrayDataInput
IOException
public int read(boolean[] b, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
public int read(short[] s) throws IOException
read
in interface ArrayDataInput
IOException
public int read(short[] s, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
public int read(char[] c) throws IOException
read
in interface ArrayDataInput
IOException
public int read(char[] c, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
public int read(int[] i) throws IOException
read
in interface ArrayDataInput
IOException
public int read(int[] i, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
public int read(long[] l) throws IOException
read
in interface ArrayDataInput
IOException
public int read(long[] l, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
public int read(float[] f) throws IOException
read
in interface ArrayDataInput
IOException
public int read(float[] f, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
public int read(double[] d) throws IOException
read
in interface ArrayDataInput
IOException
public int read(double[] d, int start, int len) throws IOException
read
in interface ArrayDataInput
IOException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.