|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream java.io.PrintStream
public class PrintStream
This class prints Java primitive values and object to a stream as
text. None of the methods in this class throw an exception. However,
errors can be detected by calling the checkError()
method.
Additionally, this stream can be designated as "autoflush" when
created so that any writes are automatically flushed to the underlying
output sink when the current line is terminated.
This class converts char's into byte's using the system default encoding.
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
PrintStream(OutputStream out)
This method intializes a new PrintStream object to write
to the specified output sink. |
|
PrintStream(OutputStream out,
boolean auto_flush)
This method intializes a new PrintStream object to write
to the specified output sink. |
Method Summary | |
---|---|
boolean |
checkError()
This method checks to see if an error has occurred on this stream. |
void |
close()
This method closes this stream and all underlying streams. |
void |
flush()
This method flushes any buffered bytes to the underlying stream and then flushes that stream as well. |
void |
print(char[] charArray)
This method prints an array of characters to the stream. |
void |
print(String str)
This method prints a String to the stream. |
void |
println()
This method prints a line separator sequence to the stream. |
void |
println(char[] charArray)
This method prints an array of characters to the stream. |
void |
println(String str)
This method prints a String to the stream. |
protected void |
setError()
This method can be called by subclasses to indicate that an error has occurred and should be reported by checkError . |
void |
write(byte[] buffer,
int offset,
int len)
This method writes len bytes from the specified array
starting at index offset into the array. |
void |
write(int oneByte)
This method writes a byte of data to the stream. |
Methods inherited from class java.io.FilterOutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrintStream(OutputStream out)
PrintStream
object to write
to the specified output sink.
out
- The OutputStream
to write to.public PrintStream(OutputStream out, boolean auto_flush)
PrintStream
object to write
to the specified output sink. This constructor also allows "auto-flush"
functionality to be specified where the stream will be flushed after
every print
or println
call, when the
write
methods with array arguments are called, or when a
single new-line character is written.
out
- The OutputStream
to write to.auto_flush
- true
to flush the stream after every
line, false
otherwiseMethod Detail |
---|
public boolean checkError()
true
forever for this stream. Before checking for an
error condition, this method flushes the stream.
true
if an error has occurred,
false
otherwiseprotected void setError()
checkError
.
public void close()
close
in class FilterOutputStream
public void flush()
flush
in class FilterOutputStream
public void print(String str)
String
to the stream. The actual
value printed depends on the system default encoding.
str
- The String
to print.public void print(char[] charArray)
charArray
- The array of characters to print.public void println()
public void println(String str)
String
to the stream. The actual
value printed depends on the system default encoding.
This method prints a line termination sequence after printing the value.
str
- The String
to print.public void println(char[] charArray)
This method prints a line termination sequence after printing the value.
charArray
- The array of characters to print.public void write(int oneByte)
write
in class FilterOutputStream
oneByte
- The byte to be writtenpublic void write(byte[] buffer, int offset, int len)
len
bytes from the specified array
starting at index offset
into the array.
write
in class FilterOutputStream
buffer
- The array of bytes to writeoffset
- The index into the array to start writing fromlen
- The number of bytes to write
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |