java.io
public class PrintStream extends FilterOutputStream implements Appendable
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.
Constructor Summary | |
---|---|
PrintStream(File file)
This method initializes a new PrintStream object to write
to the specified output File. | |
PrintStream(File file, String encoding)
This method initializes a new PrintStream object to write
to the specified output File. | |
PrintStream(String fileName)
This method initializes a new PrintStream object to write
to the specified output File. | |
PrintStream(String fileName, String encoding)
This method initializes a new PrintStream object to write
to the specified output File. | |
PrintStream(OutputStream out)
This method initializes a new PrintStream object to write
to the specified output sink. | |
PrintStream(OutputStream out, boolean auto_flush)
This method initializes a new PrintStream object to write
to the specified output sink. | |
PrintStream(OutputStream out, boolean auto_flush, String encoding)
This method initializes a new PrintStream object to write
to the specified output sink. |
Method Summary | |
---|---|
PrintStream | append(char c) |
PrintStream | append(CharSequence cs) |
PrintStream | append(CharSequence cs, int start, int end) |
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. |
PrintStream | format(String format, Object... args) |
PrintStream | format(Locale locale, String format, Object... args) |
void | print(boolean bool)
This methods prints a boolean value to the stream. |
void | print(int inum)
This method prints an integer to the stream. |
void | print(long lnum)
This method prints a long to the stream. |
void | print(float fnum)
This method prints a float to the stream. |
void | print(double dnum)
This method prints a double to the stream. |
void | print(Object obj)
This method prints an Object to the stream. |
void | print(String str)
This method prints a String to the stream. |
void | print(char ch)
This method prints a char to the stream. |
void | print(char[] charArray)
This method prints an array of characters to the stream. |
PrintStream | printf(String format, Object... args) |
PrintStream | printf(Locale locale, String format, Object... args) |
void | println()
This method prints a line separator sequence to the stream. |
void | println(boolean bool)
This methods prints a boolean value to the stream. |
void | println(int inum)
This method prints an integer to the stream. |
void | println(long lnum)
This method prints a long to the stream. |
void | println(float fnum)
This method prints a float to the stream. |
void | println(double dnum)
This method prints a double to the stream. |
void | println(Object obj)
This method prints an Object to the stream. |
void | println(String str)
This method prints a String to the stream. |
void | println(char ch)
This method prints a char to the stream. |
void | println(char[] charArray)
This method prints an array of characters 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(int oneByte)
This method writes a byte of data to the stream. |
void | write(byte[] buffer, int offset, int len)
This method writes len bytes from the specified array
starting at index offset into the array.
|
PrintStream
object to write
to the specified output File. Doesn't autoflush.
Parameters: file The File
to write to.
Throws: FileNotFoundException if an error occurs while opening the file.
Since: 1.5
PrintStream
object to write
to the specified output File. Doesn't autoflush.
Parameters: file The File
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 by
encoding
is invalid.
Since: 1.5
PrintStream
object to write
to the specified output File. Doesn't autoflush.
Parameters: fileName The name of the File
to write to.
Throws: FileNotFoundException if an error occurs while opening the file,
Since: 1.5
PrintStream
object to write
to the specified output File. Doesn't autoflush.
Parameters: fileName The name of the File
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 by
encoding
is invalid.
Since: 1.5
PrintStream
object to write
to the specified output sink. Doesn't autoflush.
Parameters: out The OutputStream
to write to.
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.
Parameters: out The OutputStream
to write to. auto_flush true
to flush the stream after every
line, false
otherwise
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.
Parameters: out The OutputStream
to write to. auto_flush true
to flush the stream after every
line, false
otherwise encoding The name of the character encoding to use for this
object.
Since: 1.5
Since: 1.5
Since: 1.5
true
forever for this stream. Before checking for an
error condition, this method flushes the stream.
Returns: true
if an error has occurred,
false
otherwise
Since: 1.5
Since: 1.5
true
values are printed as "true" and false
values are printed
as "false".
Parameters: bool The boolean
value to print
String.valueOf()
method.
Parameters: inum The int
value to be printed
String.valueOf()
method.
Parameters: lnum The long
value to be printed
String.valueOf()
method.
Parameters: fnum The float
value to be printed
String.valueOf()
method.
Parameters: dnum The double
value to be printed
Object
to the stream. The actual
value printed is determined by calling the String.valueOf()
method.
Parameters: obj The Object
to print.
String
to the stream. The actual
value printed depends on the system default encoding.
Parameters: str The String
to print.
Parameters: ch The char
value to be printed
Parameters: charArray The array of characters to print.
Since: 1.5
Since: 1.5
true
values are printed as "true" and false
values are printed
as "false".
This method prints a line termination sequence after printing the value.
Parameters: bool The boolean
value to print
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
Parameters: inum The int
value to be printed
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
Parameters: lnum The long
value to be printed
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
Parameters: fnum The float
value to be printed
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
Parameters: dnum The double
value to be printed
Object
to the stream. The actual
value printed is determined by calling the String.valueOf()
method.
This method prints a line termination sequence after printing the value.
Parameters: obj The Object
to print.
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.
Parameters: str The String
to print.
This method prints a line termination sequence after printing the value.
Parameters: ch The char
value to be printed
This method prints a line termination sequence after printing the value.
Parameters: charArray The array of characters to print.
checkError
.Parameters: oneByte The byte to be written
len
bytes from the specified array
starting at index offset
into the array.
Parameters: buffer The array of bytes to write offset The index into the array to start writing from len The number of bytes to write