| java.lang.Object java.io.OutputStream com.sun.cdc.io.j2me.UniversalOutputStream
All known Subclasses: com.sun.cdc.io.j2me.datagram.DatagramObject, com.sun.cdc.io.j2me.UniversalFilterOutputStream,
UniversalOutputStream | abstract public class UniversalOutputStream extends OutputStream implements DataOutput(Code) | | This class is a combination of several J2SE stream classes. It implements
the OutputStream and DataOutput interfaces. It also implements the normal set of print() and
println() functions. Lastly the stream may, in certain cases, be
'seeked' and have a timeout value associated with it.
Note: Printing a "\n" or calling println() will cause just a single line-feed character
to be placed in the output file.
version: 1.0 1/7/2000 |
Method Summary | |
public boolean | checkError() Flush the stream and check its error state. | public void | close() Close the stream.
Note: If this method is also implemented in a subclass, this method should
be called before the body of the code is executed. | public void | flush() Flush the stream.
Note: If this method is also implemented in a subclass, this method should
be called before the body of the code is executed. | public synchronized void | print(String s) Prints a String. | public synchronized void | print(char s) Prints an array of characters. | public void | print(Object obj) Prints an object. | public void | print(char c) Prints an character. | public void | print(int i) Prints an integer. | public void | print(long l) Prints a long. | public void | print(boolean b) Prints a boolean. | public void | println() Prints a newline. | public synchronized void | println(Object obj) Prints an object followed by a newline. | public synchronized void | println(String s) Prints a string followed by a newline. | public synchronized void | println(char s) Prints an array of characters followed by a newline. | public synchronized void | println(char c) Prints a character followed by a newline. | public synchronized void | println(int i) Prints an integer followed by a newline. | public synchronized void | println(long l) Prints a long followed by a newline. | public synchronized void | println(boolean b) Prints a boolean followed by a newline. | public void | seek(long pos) Sets the file-pointer offset, measured from the beginning of this
file, at which the next read or write occurs. | public void | setEncoding(String enc) Set the encoding for text output. | public void | setTimeout(int time) Enable or disable the timeout value for I/O performed on the stream, in
milliseconds. | public void | writeBoolean(boolean v) Writes a boolean to the underlying output stream as
a 1-byte value. | public void | writeByte(int v) Writes out a byte to the underlying output stream as
a 1-byte value. | public void | writeBytes(String s) | public void | writeChar(int v) Writes a char to the underlying output stream as a
2-byte value, high byte first. | public void | writeChars(String s) Writes a string to the underlying output stream as a sequence of
characters. | public void | writeDouble(double v) | public void | writeFloat(float v) Writes a float to the underlying output stream as int
bits. | public void | writeInt(int v) Writes an int to the underlying output stream as four
bytes, high byte first. | public void | writeLong(long v) Writes a long to the underlying output stream as eight
bytes, high byte first. | public void | writeShort(int v) Writes a short to the underlying output stream as two
bytes, high byte first. | public void | writeUTF(String str) Writes a string to the underlying output stream using UTF-8
encoding in a machine-independent manner.
First, two bytes are written to the output stream as if by the
writeShort method giving the number of bytes to
follow. | static int | writeUTF(String str, DataOutput out) Writes a string to the specified DataOutput using UTF-8 encoding in a
machine-independent manner.
First, two bytes are written to out as if by the writeShort
method giving the number of bytes to follow. |
checkError | public boolean checkError()(Code) | | Flush the stream and check its error state. Errors are cumulative;
once the stream encounters an error, this routine will return true on
all successive calls.
True if the print stream has encountered an error, either on theunderlying output stream or during a format conversion. |
close | public void close() throws IOException(Code) | | Close the stream.
Note: If this method is also implemented in a subclass, this method should
be called before the body of the code is executed. E.G.
public void close() throws IOException {
super.close();
... other things ...
}
<\pre>
|
flush | public void flush() throws IOException(Code) | | Flush the stream.
Note: If this method is also implemented in a subclass, this method should
be called before the body of the code is executed. E.G.
public void flush() throws IOException {
super.flush();
... other things ...
}
<\pre>
|
print | public synchronized void print(String s)(Code) | | Prints a String. All the data is passed through a "Writer" to ensure that the correct
character translation is performed.
Parameters: s - the String to be printed |
print | public synchronized void print(char s)(Code) | | Prints an array of characters.
Parameters: s - the array of chars to be printed |
print | public void print(Object obj)(Code) | | Prints an object.
Parameters: obj - the object to be printed |
print | public void print(char c)(Code) | | Prints an character.
Parameters: c - the character to be printed |
print | public void print(int i)(Code) | | Prints an integer.
Parameters: i - the integer to be printed |
print | public void print(long l)(Code) | | Prints a long.
Parameters: l - the long to be printed. |
print | public void print(boolean b)(Code) | | Prints a boolean.
Parameters: b - the boolean to be printed |
println | public void println()(Code) | | Prints a newline.
|
println | public synchronized void println(Object obj)(Code) | | Prints an object followed by a newline.
Parameters: obj - the object to be printed |
println | public synchronized void println(String s)(Code) | | Prints a string followed by a newline.
Parameters: s - the String to be printed |
println | public synchronized void println(char s)(Code) | | Prints an array of characters followed by a newline.
Parameters: s - the array of characters to be printed |
println | public synchronized void println(char c)(Code) | | Prints a character followed by a newline.
Parameters: c - the character to be printed |
println | public synchronized void println(int i)(Code) | | Prints an integer followed by a newline.
Parameters: i - the integer to be printed |
println | public synchronized void println(long l)(Code) | | Prints a long followed by a newline.
Parameters: l - the long to be printed |
println | public synchronized void println(boolean b)(Code) | | Prints a boolean followed by a newline.
Parameters: b - the boolean to be printed |
seek | public void seek(long pos) throws IOException, IllegalAccessException(Code) | | Sets the file-pointer offset, measured from the beginning of this
file, at which the next read or write occurs. The offset may be
set beyond the end of the file. Setting the offset beyond the end
of the file does not change the file length. The file length will
change only by writing after the offset has been set beyond the end
of the file.
Note: This function can be used only on random access streams.
other streams will result by throwing an exception.
Parameters: pos - the offset position, measured in bytes from thebeginning of the file, at which to set the filepointer. exception: IllegalAccessException - if this input stream is sequential only exception: IOException - if pos is less than0 or if an I/O error occurs. |
setEncoding | public void setEncoding(String enc) throws UnsupportedEncodingException(Code) | | Set the encoding for text output. All the print() routines
write text through a Writer that it set, by default, to the default
character encoding. This function will change the encoding to another
type.
Parameters: enc - the encoding exception: UnsupportedEncodingException - If the named encoding is not supported |
setTimeout | public void setTimeout(int time) throws IOException(Code) | | Enable or disable the timeout value for I/O performed on the stream, in
milliseconds. With this option set to a non-zero timeout,
any kind of write/print call on the stream
will block for only this amount of time. If the timeout expires,
a java.io.InterruptedIOException is raised, though the
Socket is still valid. The option must be enabled
prior to entering the blocking operation to have effect. The
timeout must be > 0.
A timeout of zero is interpreted as an infinite timeout.
Parameters: time - the time in ms. 0 = forever. |
writeBoolean | public void writeBoolean(boolean v) throws IOException(Code) | | Writes a boolean to the underlying output stream as
a 1-byte value. The value true is written out as the
value (byte)1 ; the value false is
written out as the value (byte)0 . If no exception is
thrown, the counter written is incremented by
1 .
Parameters: v - a boolean value to be written. exception: IOException - if an I/O error occurs. |
writeByte | public void writeByte(int v) throws IOException(Code) | | Writes out a byte to the underlying output stream as
a 1-byte value. If no exception is thrown, the counter
written is incremented by 1 .
Parameters: v - a byte value to be written. exception: IOException - if an I/O error occurs. |
writeChar | public void writeChar(int v) throws IOException(Code) | | Writes a char to the underlying output stream as a
2-byte value, high byte first. If no exception is thrown, the
counter written is incremented by 2 .
Parameters: v - a char value to be written. exception: IOException - if an I/O error occurs. |
writeChars | public void writeChars(String s) throws IOException(Code) | | Writes a string to the underlying output stream as a sequence of
characters. Each character is written to the data output stream as
if by the writeChar method. If no exception is
thrown, the counter written is incremented by twice
the length of s .
Parameters: s - a String value to be written. exception: IOException - if an I/O error occurs. |
writeFloat | public void writeFloat(float v) throws IOException(Code) | | Writes a float to the underlying output stream as int
bits. In no exception is thrown, the counter
written is incremented by 8 .
Parameters: v - a float to be written. exception: IOException - if an I/O error occurs. |
writeInt | public void writeInt(int v) throws IOException(Code) | | Writes an int to the underlying output stream as four
bytes, high byte first. If no exception is thrown, the counter
written is incremented by 4 .
Parameters: v - an int to be written. exception: IOException - if an I/O error occurs. |
writeLong | public void writeLong(long v) throws IOException(Code) | | Writes a long to the underlying output stream as eight
bytes, high byte first. In no exception is thrown, the counter
written is incremented by 8 .
Parameters: v - a long to be written. exception: IOException - if an I/O error occurs. |
writeShort | public void writeShort(int v) throws IOException(Code) | | Writes a short to the underlying output stream as two
bytes, high byte first. If no exception is thrown, the counter
written is incremented by 2 .
Parameters: v - a short to be written. exception: IOException - if an I/O error occurs. |
writeUTF | public void writeUTF(String str) throws IOException(Code) | | Writes a string to the underlying output stream using UTF-8
encoding in a machine-independent manner.
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 .
Parameters: str - a string to be written. exception: IOException - if an I/O error occurs. |
writeUTF | static int writeUTF(String str, DataOutput out) throws IOException(Code) | | Writes a string to the specified DataOutput using UTF-8 encoding in a
machine-independent manner.
First, two bytes are written to out 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 .
Parameters: str - a string to be written. Parameters: out - destination to write to The number of bytes written out. exception: IOException - if an I/O error occurs. |
|
|