Methods Summary |
---|
public boolean | checkError()Flush the stream and check its error state. The internal error state
is set to true when the underlying output stream throws an
IOException ,
and when the setError method is invoked.
if (charOut != null)
flush();
return trouble;
|
public void | close()Close the stream. This is done by flushing the stream and then closing
the underlying output stream. /* To avoid recursive closing */
synchronized (this) {
if (! closing) {
closing = true;
try {
charOut.close();
}
catch (IOException x) {
trouble = true;
}
charOut = null;
byteOut = null;
}
}
|
private void | ensureOpen()Check to make sure that the stream has not been closed
if (charOut == null) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Stream closed"
/* #endif */
);
}
|
public void | flush()Flush the stream. This is done by writing any buffered output bytes to
the underlying output stream and then flushing that stream.
synchronized (this) {
try {
ensureOpen();
charOut.flush();
}
catch (IOException x) {
trouble = true;
}
}
|
private void | newLine()
try {
synchronized (this) {
ensureOpen();
charOut.write('\n");
}
} catch (IOException x) {
trouble = true;
}
|
public void | print(boolean b)Print a boolean value. The string produced by {@link
java.lang.String#valueOf(boolean)} is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
{@link #write(int)} method.
write(b ? "true" : "false");
|
public void | print(char c)Print a character. The character is translated into one or more bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
{@link #write(int)} method.
write(String.valueOf(c));
|
public void | print(int i)Print an integer. The string produced by {@link
java.lang.String#valueOf(int)} is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
{@link #write(int)} method.
write(String.valueOf(i));
|
public void | print(long l)Print a long integer. The string produced by {@link
java.lang.String#valueOf(long)} is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
{@link #write(int)} method.
write(String.valueOf(l));
|
public void | print(float f)Print a floating point number. The string produced by
{@link java.lang.String#valueOf(float)} is translated
into bytes according to the platform's default character encoding,
and these bytes are written in exactly the manner of the
{@link #write(int)} method.
write(String.valueOf(f));
|
public void | print(double d)Print a double-precision floating point number. The string produced by
{@link java.lang.String#valueOf(double)} is translated
into bytes according to the platform's default character encoding,
and these bytes are written in exactly the manner of the
{@link #write(int)} method.
write(String.valueOf(d));
|
public void | print(char[] s)Print an array of characters. The characters are converted into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
{@link #write(int)} method.
write(s);
|
public void | print(java.lang.String s)Print a string. If the argument is null then the string
"null" is printed. Otherwise, the string's characters are
converted into bytes according to the platform's default character
encoding, and these bytes are written in exactly the manner of the
{@link #write(int)} method.
if (s == null) {
s = "null";
}
write(s);
|
public void | print(java.lang.Object obj)Print an object. The string produced by the {@link
java.lang.String#valueOf(Object)} method is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
{@link #write(int)} method.
write(String.valueOf(obj));
|
public void | println()Terminate the current line by writing the line separator string. The
line separator string is defined by the system property
line.separator , and is not necessarily a single newline
character ('\n' ).
newLine();
|
public void | println(boolean x)Print a boolean and then terminate the line. This method behaves as
though it invokes {@link #print(boolean)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(char x)Print a character and then terminate the line. This method behaves as
though it invokes {@link #print(char)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(int x)Print an integer and then terminate the line. This method behaves as
though it invokes {@link #print(int)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(long x)Print a long and then terminate the line. This method behaves as
though it invokes {@link #print(long)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(float x)Print a float and then terminate the line. This method behaves as
though it invokes {@link #print(float)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(double x)Print a double and then terminate the line. This method behaves as
though it invokes {@link #print(double)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(char[] x)Print an array of characters and then terminate the line. This method
behaves as though it invokes {@link #print(char[])} and
then {@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(java.lang.String x)Print a String and then terminate the line. This method behaves as
though it invokes {@link #print(String)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
public void | println(java.lang.Object x)Print an Object and then terminate the line. This method behaves as
though it invokes {@link #print(Object)} and then
{@link #println()} .
synchronized (this) {
print(x);
newLine();
}
|
protected void | setError()Set the error state of the stream to true .
trouble = true;
|
private void | write(java.lang.String s)
try {
synchronized (this) {
ensureOpen();
charOut.write(s);
}
} catch (IOException x) {
trouble = true;
}
|
public void | write(int b)Write the specified byte to this stream.
Note that the byte is written as given; to write a character that
will be translated according to the platform's default character
encoding, use the print(char) or println(char)
methods.
try {
synchronized (this) {
ensureOpen();
byteOut.write(b);
}
} catch (IOException x) {
trouble = true;
}
|
public void | write(byte[] buf, int off, int len)Write len bytes from the specified byte array starting at
offset off to this stream.
Note that the bytes will be written as given; to write characters
that will be translated according to the platform's default character
encoding, use the print(char) or println(char)
methods.
try {
synchronized (this) {
ensureOpen();
byteOut.write(buf, off, len);
}
} catch (IOException x) {
trouble = true;
}
|
private void | write(char[] buf)
try {
synchronized (this) {
ensureOpen();
charOut.write(buf);
}
} catch (IOException x) {
trouble = true;
}
|