public class BufferedDataOutputStream extends java.io.BufferedOutputStream implements ArrayDataOutput
Note that there is substantial duplication of code to minimize method invocations. However simple output methods were used where empirical tests seemed to indicate that the simpler method did not cost any time. It seems likely that most of these variations will be washed out across different compilers and users who wish to tune the method for their particular system may wish to compare the the implementation of write(int[], int, int) with write(float[], int, int).
Testing and timing for this class is performed in the nom.tam.util.test.BufferedFileTester class.
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 |
---|
BufferedDataOutputStream(java.io.OutputStream o)
Use the BufferedOutputStream constructor
|
BufferedDataOutputStream(java.io.OutputStream o,
int bufLength)
Use the BufferedOutputStream constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkBuf(int need)
See if there is enough space to add something to the buffer.
|
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(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[] 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(java.lang.String[] s)
Write an array of Strings.
|
void |
write(java.lang.String[] s,
int start,
int len)
Write a segment of an array of Strings.
|
void |
writeArray(java.lang.Object o)
This routine provides efficient writing of arrays of any primitive type.
|
void |
writeBoolean(boolean b) |
void |
writeByte(int b) |
void |
writeBytes(java.lang.String s) |
void |
writeChar(int c) |
void |
writeChars(java.lang.String s) |
void |
writeDouble(double d) |
void |
writeFloat(float f) |
void |
writeInt(int i) |
void |
writeLong(long l) |
void |
writePrimitiveArray(java.lang.Object o)
Deprecated.
use
writeArray(Object) instead |
void |
writeShort(int s)
Write a short value.
|
void |
writeUTF(java.lang.String s) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flush
public BufferedDataOutputStream(java.io.OutputStream o)
o
- An open output stream.public BufferedDataOutputStream(java.io.OutputStream o, int bufLength)
o
- An open output stream.bufLength
- The buffer size.protected void checkBuf(int need) throws java.io.IOException
need
- the number of bytes that should be available in the buffer.java.io.IOException
- if the underlying write operation failspublic void write(boolean[] b) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
b
- array of boolean's.java.io.IOException
- if one of the underlying write operations failedpublic void write(boolean[] b, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
b
- array of boolean's.start
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(char[] c) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
c
- array of char's.java.io.IOException
- if one of the underlying write operations failedpublic void write(char[] c, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
c
- array of char's.start
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(double[] d) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
d
- array of double's.java.io.IOException
- if one of the underlying write operations failedpublic void write(double[] d, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
d
- array of double's.start
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(float[] f) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
f
- array of float's.java.io.IOException
- if one of the underlying write operations failedpublic void write(float[] f, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
f
- array of float's.start
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(int[] i) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
i
- array of int'sjava.io.IOException
- if one of the underlying write operations failedpublic void write(int[] i, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
i
- array of int'sstart
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(long[] l) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
l
- array of longsjava.io.IOException
- if one of the underlying write operations failedpublic void write(long[] l, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
l
- array of longsstart
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(short[] s) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the value to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(short[] s, int start, int length) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the value to writestart
- start index in the arraylength
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(java.lang.String[] s) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the array to writejava.io.IOException
- if one of the underlying write operations failedpublic void write(java.lang.String[] s, int start, int len) throws java.io.IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the array to writestart
- start index in the arraylen
- number of array elements to writejava.io.IOException
- if one of the underlying write operations failedpublic void writeArray(java.lang.Object o) throws java.io.IOException
ArrayDataOutput
writeArray
in interface ArrayDataOutput
o
- The object to be written. It must be an array of a primitive
type, Object, or String.java.io.IOException
- if one of the underlying write operations failedpublic void writeBoolean(boolean b) throws java.io.IOException
writeBoolean
in interface java.io.DataOutput
java.io.IOException
public void writeByte(int b) throws java.io.IOException
writeByte
in interface java.io.DataOutput
java.io.IOException
public void writeBytes(java.lang.String s) throws java.io.IOException
writeBytes
in interface java.io.DataOutput
java.io.IOException
public void writeChar(int c) throws java.io.IOException
writeChar
in interface java.io.DataOutput
java.io.IOException
public void writeChars(java.lang.String s) throws java.io.IOException
writeChars
in interface java.io.DataOutput
java.io.IOException
public void writeDouble(double d) throws java.io.IOException
writeDouble
in interface java.io.DataOutput
java.io.IOException
public void writeFloat(float f) throws java.io.IOException
writeFloat
in interface java.io.DataOutput
java.io.IOException
public void writeInt(int i) throws java.io.IOException
writeInt
in interface java.io.DataOutput
java.io.IOException
public void writeLong(long l) throws java.io.IOException
writeLong
in interface java.io.DataOutput
java.io.IOException
@Deprecated public void writePrimitiveArray(java.lang.Object o) throws java.io.IOException
writeArray(Object)
insteadwriteArray(Object)
.o
- The object to be written.java.io.IOException
- if one of the underlying write operations failedpublic void writeShort(int s) throws java.io.IOException
writeShort
in interface java.io.DataOutput
java.io.IOException
public void writeUTF(java.lang.String s) throws java.io.IOException
writeUTF
in interface java.io.DataOutput
java.io.IOException