Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
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 | |
| |
| |
| |
| |
| |
| |
|
Method Summary | |
PrintStream |
|
PrintStream |
|
PrintStream |
|
boolean |
|
void |
|
void |
|
PrintStream | |
PrintStream | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
PrintStream | |
PrintStream | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
protected void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public PrintStream(File file) throws FileNotFoundException
This method initializes a newPrintStream
object to write to the specified output File. Doesn't autoflush.
- Parameters:
file
- TheFile
to write to.
- Throws:
FileNotFoundException
- if an error occurs while opening the file.
- Since:
- 1.5
public PrintStream(File file, String encoding) throws FileNotFoundException, UnsupportedEncodingException
This method initializes a newPrintStream
object to write to the specified output File. Doesn't autoflush.
- Parameters:
file
- TheFile
to write to.encoding
- The name of the character encoding to use for this object.
- Throws:
FileNotFoundException
- If an error occurs while opening the file.UnsupportedEncodingException
- If the charset specified byencoding
is invalid.
- Since:
- 1.5
public PrintStream(OutputStream out)
This method intializes a newPrintStream
object to write to the specified output sink.
- Parameters:
out
- TheOutputStream
to write to.
public PrintStream(OutputStream out, boolean auto_flush)
This method intializes a newPrintStream
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 everyprintln
call, when thewrite
methods with array arguments are called, or when a single new-line character is written.
- Parameters:
out
- TheOutputStream
to write to.auto_flush
-true
to flush the stream after every line,false
otherwise
public PrintStream(OutputStream out, boolean auto_flush, String encoding) throws UnsupportedEncodingException
This method intializes a newPrintStream
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 everyprintln
call, when thewrite
methods with array arguments are called, or when a single new-line character is written.
- Parameters:
out
- TheOutputStream
to write to.auto_flush
-true
to flush the stream after every line,false
otherwiseencoding
- The name of the character encoding to use for this object.
public PrintStream(String fileName) throws FileNotFoundException
This method initializes a newPrintStream
object to write to the specified output File. Doesn't autoflush.
- Parameters:
fileName
- The name of theFile
to write to.
- Throws:
FileNotFoundException
- if an error occurs while opening the file,
- Since:
- 1.5
public PrintStream(String fileName, String encoding) throws FileNotFoundException, UnsupportedEncodingException
This method initializes a newPrintStream
object to write to the specified output File. Doesn't autoflush.
- Parameters:
fileName
- The name of theFile
to write to.encoding
- The name of the character encoding to use for this object.
- Throws:
FileNotFoundException
- if an error occurs while opening the file.UnsupportedEncodingException
- If the charset specified byencoding
is invalid.
- Since:
- 1.5
public PrintStream append(CharSequence cs)
- Specified by:
- append in interface Appendable
- Since:
- 1.5
public PrintStream append(CharSequence cs, int start, int end)
- Specified by:
- append in interface Appendable
- Since:
- 1.5
public boolean checkError()
This method checks to see if an error has occurred on this stream. Note that once an error has occurred, this method will continue to reporttrue
forever for this stream. Before checking for an error condition, this method flushes the stream.
- Returns:
true
if an error has occurred,false
otherwise
public void close()
This method closes this stream and all underlying streams.
- Specified by:
- close in interface Closeable
- close in interface AutoCloseable
- Overrides:
- close in interface FilterOutputStream
public void flush()
This method flushes any buffered bytes to the underlying stream and then flushes that stream as well.
- Overrides:
- flush in interface FilterOutputStream
public void print(boolean bool)
This methods prints a boolean value to the stream.true
values are printed as "true" andfalse
values are printed as "false".
- Parameters:
bool
- Theboolean
value to print
public void print(char ch)
This method prints a char to the stream. The actual value printed is determined by the character encoding in use.
- Parameters:
ch
- Thechar
value to be printed
public void print(char[] charArray)
This method prints an array of characters to the stream. The actual value printed depends on the system default encoding.
- Parameters:
charArray
- The array of characters to print.
public void print(double dnum)
This method prints a double to the stream. The value printed is determined using theString.valueOf()
method.
- Parameters:
dnum
- Thedouble
value to be printed
public void print(float fnum)
This method prints a float to the stream. The value printed is determined using theString.valueOf()
method.
- Parameters:
fnum
- Thefloat
value to be printed
public void print(int inum)
This method prints an integer to the stream. The value printed is determined using theString.valueOf()
method.
- Parameters:
inum
- Theint
value to be printed
public void print(Object obj)
This method prints anObject
to the stream. The actual value printed is determined by calling theString.valueOf()
method.
- Parameters:
obj
- TheObject
to print.
public void print(String str)
This method prints aString
to the stream. The actual value printed depends on the system default encoding.
- Parameters:
str
- TheString
to print.
public void print(long lnum)
This method prints a long to the stream. The value printed is determined using theString.valueOf()
method.
- Parameters:
lnum
- Thelong
value to be printed
public void println()
This method prints a line separator sequence to the stream. The value printed is determined by the system propertyline.separator and is not necessarily the Unix '\n' newline character.
public void println(boolean bool)
This methods prints a boolean value to the stream.true
values are printed as "true" andfalse
values are printed as "false".This method prints a line termination sequence after printing the value.
- Parameters:
bool
- Theboolean
value to print
public void println(char ch)
This method prints a char to the stream. The actual value printed is determined by the character encoding in use.This method prints a line termination sequence after printing the value.
- Parameters:
ch
- Thechar
value to be printed
public void println(char[] charArray)
This method prints an array of characters to the stream. The actual value printed depends on the system default encoding.This method prints a line termination sequence after printing the value.
- Parameters:
charArray
- The array of characters to print.
public void println(double dnum)
This method prints a double to the stream. The value printed is determined using theString.valueOf()
method.This method prints a line termination sequence after printing the value.
- Parameters:
dnum
- Thedouble
value to be printed
public void println(float fnum)
This method prints a float to the stream. The value printed is determined using theString.valueOf()
method.This method prints a line termination sequence after printing the value.
- Parameters:
fnum
- Thefloat
value to be printed
public void println(int inum)
This method prints an integer to the stream. The value printed is determined using theString.valueOf()
method.This method prints a line termination sequence after printing the value.
- Parameters:
inum
- Theint
value to be printed
public void println(Object obj)
This method prints anObject
to the stream. The actual value printed is determined by calling theString.valueOf()
method.This method prints a line termination sequence after printing the value.
- Parameters:
obj
- TheObject
to print.
public void println(String str)
This method prints aString
to the stream. The actual value printed depends on the system default encoding.This method prints a line termination sequence after printing the value.
- Parameters:
str
- TheString
to print.
public void println(long lnum)
This method prints a long to the stream. The value printed is determined using theString.valueOf()
method.This method prints a line termination sequence after printing the value.
- Parameters:
lnum
- Thelong
value to be printed
protected void setError()
This method can be called by subclasses to indicate that an error has occurred and should be reported bycheckError
.
public void write(byte[] buffer, int offset, int len)
This method writeslen
bytes from the specified array starting at indexoffset
into the array.
- Overrides:
- write in interface FilterOutputStream
- Parameters:
buffer
- The array of bytes to writeoffset
- The index into the array to start writing fromlen
- The number of bytes to write
public void write(int oneByte)
This method writes a byte of data to the stream. If auto-flush is enabled, printing a newline character will cause the stream to be flushed after the character is written.
- Overrides:
- write in interface FilterOutputStream
- Parameters:
oneByte
- The byte to be written