public class BufferedDataOutputStream extends 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.
buf, count
out
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(OutputStream o)
Use the BufferedOutputStream constructor
|
BufferedDataOutputStream(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(String[] s)
Write an array of Strings.
|
void |
write(String[] s,
int start,
int len)
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 |
writePrimitiveArray(Object o)
Deprecated.
use
writeArray(Object) instead |
void |
writeShort(int s)
Write a short value.
|
void |
writeUTF(String s) |
flush, write, write
close, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flush
write, write, write
public BufferedDataOutputStream(OutputStream o)
o
- An open output stream.public BufferedDataOutputStream(OutputStream o, int bufLength)
o
- An open output stream.bufLength
- The buffer size.protected void checkBuf(int need) throws IOException
need
- the number of bytes that should be available in the buffer.IOException
- if the underlying write operation failspublic 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(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[] 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 len) throws IOException
ArrayDataOutput
write
in interface ArrayDataOutput
s
- the array to writestart
- start index in the arraylen
- 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
@Deprecated public void writePrimitiveArray(Object o) throws IOException
writeArray(Object)
insteadwriteArray(Object)
.o
- The object to be written.IOException
- if one of the underlying write operations failedpublic 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.