|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
com.sun.squawk.io.j2me.channel.ChannelOutputStream
public class ChannelOutputStream
ChannelOutputStream
Constructor Summary | |
---|---|
ChannelOutputStream(Protocol parent)
|
Method Summary | |
---|---|
void |
close()
Closes this output stream and releases any system resources associated with this stream. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
void |
write(byte[] b)
Writes to the output stream all the bytes in array b . |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this output stream. |
void |
write(int v)
Writes the specified byte to this output stream. |
void |
writeBoolean(boolean v)
Writes a boolean value to this output stream. |
void |
writeByte(int v)
Writes out a byte to the underlying output stream as
a 1-byte value. |
void |
writeChar(int v)
Writes a char value, which
is comprised of two bytes, to the
output stream. |
void |
writeChars(String s)
Writes a string to the underlying output stream as a sequence of characters. |
void |
writeDouble(double v)
Writes a 64 bit double. |
void |
writeFloat(float v)
Writes a 32 bit float. |
void |
writeInt(int v)
Writes an int value, which is
comprised of four bytes, to the output stream. |
void |
writeLong(long v)
Writes an long value, which is
comprised of four bytes, to the output stream. |
void |
writeShort(int v)
Writes two bytes to the output stream to represent the value of the argument. |
void |
writeUTF(String str)
Writes a string to the underlying output stream using UTF-8 encoding in a machine-independent manner. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChannelOutputStream(Protocol parent) throws IOException
IOException
Method Detail |
---|
public void flush() throws IOException
OutputStream
flush
is
that calling it is an indication that, if any bytes previously
written have been buffered by the implementation of the output
stream, such bytes should immediately be written to their
intended destination.
The flush
method of OutputStream
does nothing.
flush
in class OutputStream
IOException
- if an I/O error occurs.public void close() throws IOException
OutputStream
close
is that it closes the output stream. A closed stream cannot perform
output operations and cannot be reopened.
The close
method of OutputStream
does nothing.
close
in class OutputStream
IOException
- if an I/O error occurs.public void write(int v) throws IOException
OutputStream
write
is that one byte is written
to the output stream. The byte to be written is the eight
low-order bits of the argument b
. The 24
high-order bits of b
are ignored.
Subclasses of OutputStream
must provide an
implementation for this method.
write
in interface DataOutput
write
in class OutputStream
v
- the byte
.
IOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void writeShort(int v) throws IOException
DataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be
read by the readShort
method
of interface DataInput
, which
will then return a short
equal
to (short)v
.
writeShort
in interface DataOutput
v
- the short
value to be written.
IOException
- if an I/O error occurs.public void writeChar(int v) throws IOException
DataOutput
char
value, which
is comprised of two bytes, to the
output stream.
The byte values to be written, in the order
shown, are:
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be
read by the readChar
method
of interface DataInput
, which
will then return a char
equal
to (char)v
.
writeChar
in interface DataOutput
v
- the char
value to be written.
IOException
- if an I/O error occurs.public void writeInt(int v) throws IOException
DataOutput
int
value, which is
comprised of four bytes, to the output stream.
The byte values to be written, in the order
shown, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read
by the readInt
method of interface
DataInput
, which will then
return an int
equal to v
.
writeInt
in interface DataOutput
v
- the int
value to be written.
IOException
- if an I/O error occurs.public void writeLong(long v) throws IOException
DataOutput
long
value, which is
comprised of four bytes, to the output stream.
The byte values to be written, in the order
shown, are:
(byte)(0xff & (v >> 56))
(byte)(0xff & (v >> 48))
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be
read by the readLong
method
of interface DataInput
, which
will then return a long
equal
to v
.
writeLong
in interface DataOutput
v
- the long
value to be written.
IOException
- if an I/O error occurs.public void write(byte[] b, int off, int len) throws IOException
OutputStream
len
bytes from the specified byte array
starting at offset off
to this output stream.
The general contract for write(b, off, len)
is that
some of the bytes in the array b
are written to the
output stream in order; element b[off]
is the first
byte written and b[off+len-1]
is the last byte written
by this operation.
The write
method of OutputStream
calls
the write method of one argument on each of the bytes to be
written out. Subclasses are encouraged to override this method and
provide a more efficient implementation.
If b
is null
, a
NullPointerException
is thrown.
If off
is negative, or len
is negative, or
off+len
is greater than the length of the array
b
, then an IndexOutOfBoundsException is thrown.
write
in interface DataOutput
write
in class OutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.
IOException
- if an I/O error occurs. In particular,
an IOException
is thrown if the output
stream is closed.public void write(byte[] b) throws IOException
b
.
If b
is null
,
a NullPointerException
is thrown.
If b.length
is zero, then
no bytes are written. Otherwise, the byte
b[0]
is written first, then
b[1]
, and so on; the last byte
written is b[b.length-1]
.
write
in interface DataOutput
write
in class OutputStream
b
- the data.
IOException
- if an I/O error occurs.OutputStream.write(byte[], int, int)
public final void writeByte(int v) throws IOException
byte
to the underlying output stream as
a 1-byte value. If no exception is thrown, the counter
written
is incremented by 1
.
writeByte
in interface DataOutput
v
- a byte
value to be written.
IOException
- if an I/O error occurs.public final void writeFloat(float v) throws IOException
writeFloat
in interface DataOutput
v
- the float value to be written
IOException
- if an I/O error occurs.public final void writeDouble(double v) throws IOException
writeDouble
in interface DataOutput
v
- the double value to be written
IOException
- if an I/O error occurs.public void writeBoolean(boolean v) throws IOException
boolean
value to this output stream.
If the argument v
is true
, the value (byte)1
is written; if v
is false
,
the value (byte)0
is written.
The byte written by this method may
be read by the readBoolean
method of interface DataInput
,
which will then return a boolean
equal to v
.
writeBoolean
in interface DataOutput
v
- the boolean to be written.
IOException
- if an I/O error occurs.public final void writeChars(String s) throws IOException
writeChar
method. If no exception is
thrown, the counter written
is incremented by twice
the length of s
.
writeChars
in interface DataOutput
s
- a String
value to be written.
IOException
- if an I/O error occurs.DataOutputStream.writeChar(int)
public final void writeUTF(String str) throws IOException
First, two bytes are written to the output stream as if by the
writeShort
method giving the number of bytes to
follow. This value is the number of bytes actually written out,
not the length of the string. Following the length, each character
of the string is output, in sequence, using the UTF-8 encoding
for the character. If no exception is thrown, the counter
written
is incremented by the total number of
bytes written to the output stream. This will be at least two
plus the length of str
, and at most two plus
thrice the length of str
.
writeUTF
in interface DataOutput
str
- a string to be written.
IOException
- if an I/O error occurs.
|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |