|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
nom.tam.util.BufferedDataOutputStream
public class BufferedDataOutputStream
This class is intended for high performance I/O in scientific applications. It combines the functionality of the BufferedOutputStream and the DataOutputStream as well as more efficient handling of arrays. This minimizes the number of method calls that are required to write data. Informal tests of this method show that it can be as much as 10 times faster than using a DataOutputStream layered on a BufferedOutputStream for writing large arrays. The performance gain on scalars or small arrays will be less but there should probably never be substantial degradation of performance. One routine is added to the public interface of DataOutput, writePrimitiveArray. This routine provides efficient protocols for writing arrays. Note that there is substantial duplication of code to minimize method invocations.
Field Summary |
---|
Fields inherited from class java.io.BufferedOutputStream |
---|
buf, count |
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
BufferedDataOutputStream(java.io.OutputStream o)
Use the BufferedOutputStream constructor |
|
BufferedDataOutputStream(java.io.OutputStream o,
int bufLength)
Use the BufferedOutputStream constructor |
Method Summary | |
---|---|
static void |
main(java.lang.String[] args)
Test this class |
void |
writeBoolean(boolean b)
Write a boolean value |
protected void |
writeBooleanArray(boolean[] b)
Write an array of booleans. |
void |
writeByte(int b)
Write a byte value. |
void |
writeBytes(java.lang.String s)
Write a string using the local protocol to convert char's to bytes. |
void |
writeChar(int c)
Write a char value. |
protected void |
writeCharArray(char[] c)
Write an array of char's. |
void |
writeChars(java.lang.String s)
Write a string as an array of chars. |
void |
writeDouble(double d)
Write a double value. |
protected void |
writeDoubleArray(double[] d)
Write an array of doubles. |
void |
writeFloat(float f)
Write a float value. |
protected void |
writeFloatArray(float[] f)
Write an array of floats. |
void |
writeInt(int i)
Write an integer value. |
protected void |
writeIntArray(int[] i)
Write an array of int's. |
void |
writeLong(long l)
Write a long value. |
protected void |
writeLongArray(long[] l)
Write an array of longs. |
void |
writePrimitiveArray(java.lang.Object o)
This routine provides efficient writing of arrays of any primitive type. |
void |
writeShort(int s)
Write a short value. |
protected void |
writeShortArray(short[] s)
Write an array of shorts. |
protected void |
writeStringArray(java.lang.String[] s)
Write an array of Strings -- equivalent to calling writeBytes for each string. |
void |
writeUTF(java.lang.String s)
Write a string as a UTF. |
Methods inherited from class java.io.BufferedOutputStream |
---|
flush, write, write |
Methods inherited from class java.io.FilterOutputStream |
---|
close, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.io.DataOutput |
---|
write, write, write |
Constructor Detail |
---|
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.Method Detail |
---|
public void writeBoolean(boolean b) throws java.io.IOException
writeBoolean
in interface java.io.DataOutput
b
- The value to be written. Externally true is represented as
a byte of 1 and false as a byte value of 0.
java.io.IOException
public void writeByte(int b) throws java.io.IOException
writeByte
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 writeShort(int s) throws java.io.IOException
writeShort
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 writeLong(long l) throws java.io.IOException
writeLong
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 writeDouble(double d) throws java.io.IOException
writeDouble
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
s
- The string to be written.
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 writeUTF(java.lang.String s) throws java.io.IOException
writeUTF
in interface java.io.DataOutput
java.io.IOException
public void writePrimitiveArray(java.lang.Object o) throws java.io.IOException
o
- The object to be written. It must be an array of a primitive
type, Object, or String.
java.io.IOException
protected void writeBooleanArray(boolean[] b) throws java.io.IOException
java.io.IOException
protected void writeShortArray(short[] s) throws java.io.IOException
java.io.IOException
protected void writeCharArray(char[] c) throws java.io.IOException
java.io.IOException
protected void writeIntArray(int[] i) throws java.io.IOException
java.io.IOException
protected void writeLongArray(long[] l) throws java.io.IOException
java.io.IOException
protected void writeFloatArray(float[] f) throws java.io.IOException
java.io.IOException
protected void writeDoubleArray(double[] d) throws java.io.IOException
java.io.IOException
protected void writeStringArray(java.lang.String[] s) throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |