Sunday 10 March 2013

PrintStream


PrintStream

Declaration
public class PrintStream extends OutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.PrintStream
Description
A PrintStream adds functionality to another output stream, namely the ability to print representations of
various data values conveniently. Two other features are provided as well. Unlike other output streams, a
PrintStream never throws an IOException; instead, exceptional situations merely set an internal flag
that can be tested via the checkError method.
All characters printed by a PrintStream are converted into bytes using the platform’s default character
encoding.


Constructors
PrintStream(OutputStream out)
Methods
boolean checkError()
void close()
void flush()
void print(boolean b)
void print(char c)
void print(char[] s)
void print(double d)
void print(float f)
void print(int i)
void print(long l)
void print(java.lang.Object obj)
void print(java.lang.String s)
void println()
void println(boolean x)
void println(char x)
void println(char[] x)
void println(double x)
void println(float x)
void println(int x)
void println(long x)
void println(java.lang.Object x)


void println(java.lang.String x)
protected void setError()
void write(byte[] buf, int off, int len)
void write(int b)


Methods inherited from class Object
equals(Object), getClass(), hashCode(), notify(), notifyAll(), toString(), wait(),
wait(), wait()
Methods inherited from class OutputStream
write(byte[])


Constructors
PrintStream(OutputStream)
Declaration:
public PrintStream(java.io.OutputStream out)
Description:
Create a new print stream. This stream will not flush automatically.
Parameters:
out - The output stream to which values and objects will be printed


Methods
flush()
Declaration:
public void flush()
Description:
Flush the stream. This is done by writing any buffered output bytes to the underlying output stream and then
flushing that stream.
Overrides: flush in class OutputStream
See Also: OutputStream.flush()
close()
Declaration:
public void close()

Description:
Close the stream. This is done by flushing the stream and then closing the underlying output stream.
Overrides: close in class OutputStream
See Also: OutputStream.close()
checkError()
Declaration:
public boolean checkError()
Description:
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.
Returns: True if and only if this stream has encountered an IOException, or the setError method
has been invoked
setError()
Declaration:
protected void setError()
Description:
Set the error state of the stream to true.
Since: JDK1.1
write(int)
Declaration:
public void write(int b)
Description:
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.
Overrides: write in class OutputStream
Parameters:
b - The byte to be written
See Also: print(char), println(char)
write(byte[], int, int)
Declaration:
public void write(byte[] buf, int off, int len)
Description:
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.
Overrides: write in class OutputStream

Parameters:
buf - A byte array
off - Offset from which to start taking bytes
len - Number of bytes to write
print(boolean)
Declaration:
public void print(boolean b)
Description:
Print a boolean value. The string produced by 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 write(int) method.
Parameters:
b - The boolean to be printed








No comments:

Post a Comment