|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.io.OutputStream jcontrol.io.DataOutputStream
public abstract class DataOutputStream
A DataOutputStreams allows the output of java basic types (char, short, int,
boolean) to any OutputStream. It is possible to select a specific endianess for
the contained data. An internal byte counter is used to track
information on the number of bytes produced by writing to this DataOutputStream.
The counter can be read through method size()
.
A DataOutputStream can not be instantiated directly,
instead an instance must be created through the static method
createDataOutputStream( OutputStream out, int endianess)
.
Note: If the byte counter reaches the limit (Integer.MAX_INT
),
it overflows.
Field Summary | |
---|---|
static int |
BIG_ENDIAN
Big endian mode. |
static int |
LITTLE_ENDIAN
Little endian mode. |
Constructor Summary | |
---|---|
DataOutputStream()
|
Method Summary | |
---|---|
static DataOutputStream |
createDataOutputStream(OutputStream out)
Creates a new DataOutputStream with big endian data layout. |
static DataOutputStream |
createDataOutputStream(OutputStream out,
int endianess)
Creates a new DataOutputStream. |
abstract int |
size()
Returns the internal byte counter. |
abstract void |
write(byte[] b)
Writes an array of bytes to the OutputStream. |
abstract void |
write(byte[] b,
int start,
int length)
Writes a part of an array to the OutputStream. |
abstract void |
write(int b)
Writes a single byte to the OutputStream. |
abstract void |
writeBoolean(boolean b)
Writes a boolean to the DataOutputStream. |
abstract void |
writeChar(char c)
Writes a char to the DataOutputStream and increases the internal
byte counter by 2, the size of a char. |
abstract void |
writeDouble(double d)
Writes an double to the DataOutputStream and increases the internal
byte counter by 8, the size of a double . |
abstract void |
writeFloat(float f)
Writes an float to the DataOutputStream and increases the internal
byte counter by 4, the size of a float . |
abstract void |
writeInt(int i)
Writes an int to the DataOutputStream and increases the internal
byte counter by 4, the size of an int . |
abstract void |
writeLong(long l)
Writes an long to the DataOutputStream and increases the internal
byte counter by 8, the size of a long . |
abstract void |
writeShort(short s)
Writes a short to the DataOutputStream and increases the internal
byte counter by 2, the size of a short . |
Methods inherited from class jcontrol.io.OutputStream |
---|
close, flush |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Field Detail |
---|
public static final int BIG_ENDIAN
public static final int LITTLE_ENDIAN
Constructor Detail |
---|
public DataOutputStream()
Method Detail |
---|
public static DataOutputStream createDataOutputStream(OutputStream out, int endianess)
out
- OutputStream to useendianess
- BIG_ENDIAN
or LITTLE_ENDIAN
public static DataOutputStream createDataOutputStream(OutputStream out)
out
- OutputStream to use
public abstract void writeBoolean(boolean b) throws IOException
boolean
to the DataOutputStream. The boolean is represented
as a byte value of 0
(false) or 1
(true). The internal
byte counter is increased by 1.
b
- boolean to write
IOException
- occurs on I/O errors or when the stream was closedpublic abstract void writeChar(char c) throws IOException
char
to the DataOutputStream and increases the internal
byte counter by 2, the size of a char.
- Parameters:
c
- character to write
- Throws:
IOException
- occurs on I/O errors or when the stream was closed
public abstract void writeShort(short s) throws IOException
short
to the DataOutputStream and increases the internal
byte counter by 2, the size of a short
.
s
- short to write
IOException
- occurs on I/O errors or when the stream was closedpublic abstract void writeInt(int i) throws IOException
int
to the DataOutputStream and increases the internal
byte counter by 4, the size of an int
.
i
- integer to write
IOException
- occurs on I/O errors or when the stream was closedpublic abstract void writeLong(long l) throws IOException
long
to the DataOutputStream and increases the internal
byte counter by 8, the size of a long
.
l
- long to write
IOException
- occurs on I/O errors or when the stream was closedpublic abstract void writeFloat(float f) throws IOException
float
to the DataOutputStream and increases the internal
byte counter by 4, the size of a float
.
f
- float to write
IOException
- occurs on I/O errors or when the stream was closedpublic abstract void writeDouble(double d) throws IOException
double
to the DataOutputStream and increases the internal
byte counter by 8, the size of a double
.
d
- double to write
IOException
- occurs on I/O errors or when the stream was closedpublic abstract int size()
public abstract void write(int b) throws IOException
write
in class OutputStream
b
- byte to write
IOException
- occurs on I/O errors or when the stream is closedpublic abstract void write(byte[] b) throws IOException
write
in class OutputStream
b
- array containing the data to send
IOException
- occurs on I/O errors or when the stream is closedpublic abstract void write(byte[] b, int start, int length) throws IOException
write
in class OutputStream
b
- array containing the data to sendstart
- index of the first byte to send in the arraylength
- number of bytes to send
IOException
- occurs on I/O errors or when the stream is closed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |