java.io
Class PrintStream
- Appendable, Closeable, Flushable
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.
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(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.
|
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 | 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, java.lang.Object... args)
|
PrintStream | format(Locale locale, String format, java.lang.Object... args)
|
void | print(boolean bool) - This methods prints a boolean value 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.
|
void | print(double dnum) - This method prints a double to the stream.
|
void | print(float fnum) - This method prints a float to the stream.
|
void | print(int inum) - This method prints an integer 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(long lnum) - This method prints a long to the stream.
|
PrintStream | printf(String format, java.lang.Object... args)
|
PrintStream | printf(Locale locale, String format, java.lang.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(char ch) - This method prints a char to the stream.
|
void | println(char[] charArray) - This method prints an array of characters to the stream.
|
void | println(double dnum) - This method prints a double to the stream.
|
void | println(float fnum) - This method prints a float to the stream.
|
void | println(int inum) - This method prints an integer 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(long lnum) - This method prints a long 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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
PrintStream
public PrintStream(File file)
throws FileNotFoundException
This method initializes a new PrintStream
object to write
to the specified output File. Doesn't autoflush.
file
- The File
to write to.
PrintStream
public PrintStream(OutputStream out)
This method initializes a new PrintStream
object to write
to the specified output sink. Doesn't autoflush.
out
- The OutputStream
to write to.
PrintStream
public PrintStream(OutputStream out,
boolean auto_flush)
This method initializes a new
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
otherwise
PrintStream
public PrintStream(OutputStream out,
boolean auto_flush,
String encoding)
throws UnsupportedEncodingException
This method initializes a new
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
otherwiseencoding
- The name of the character encoding to use for this
object.
PrintStream
public PrintStream(String fileName)
throws FileNotFoundException
This method initializes a new PrintStream
object to write
to the specified output File. Doesn't autoflush.
fileName
- The name of the File
to write to.
checkError
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 report
true
forever for this stream. Before checking for an
error condition, this method flushes the stream.
true
if an error has occurred,
false
otherwise
print
public void print(boolean bool)
This methods prints a boolean value to the stream. true
values are printed as "true" and false
values are printed
as "false".
bool
- The boolean
value to print
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.
ch
- The char
value to be printed
print
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.
charArray
- The array of characters to print.
print
public void print(double dnum)
This method prints a double to the stream. The value printed is
determined using the String.valueOf()
method.
dnum
- The double
value to be printed
print
public void print(float fnum)
This method prints a float to the stream. The value printed is
determined using the String.valueOf()
method.
fnum
- The float
value to be printed
print
public void print(int inum)
This method prints an integer to the stream. The value printed is
determined using the String.valueOf()
method.
inum
- The int
value to be printed
print
public void print(Object obj)
This method prints an Object
to the stream. The actual
value printed is determined by calling the String.valueOf()
method.
obj
- The Object
to print.
print
public void print(String str)
This method prints a String
to the stream. The actual
value printed depends on the system default encoding.
str
- The String
to print.
print
public void print(long lnum)
This method prints a long to the stream. The value printed is
determined using the String.valueOf()
method.
lnum
- The long
value to be printed
println
public void println()
This method prints a line separator sequence to the stream. The value
printed is determined by the system property
line.separator
and is not necessarily the Unix '\n' newline character.
println
public void println(boolean bool)
This methods prints a boolean value to the stream.
true
values are printed as "true" and
false
values are printed
as "false".
This method prints a line termination sequence after printing the value.
bool
- The boolean
value to print
println
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.
ch
- The char
value to be printed
println
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.
charArray
- The array of characters to print.
println
public void println(double dnum)
This method prints a double to the stream. The value printed is
determined using the
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
dnum
- The double
value to be printed
println
public void println(float fnum)
This method prints a float to the stream. The value printed is
determined using the
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
fnum
- The float
value to be printed
println
public void println(int inum)
This method prints an integer to the stream. The value printed is
determined using the
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
inum
- The int
value to be printed
println
public void println(Object obj)
This method prints an
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.
obj
- The Object
to print.
println
public void println(String str)
This method prints a
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.
println
public void println(long lnum)
This method prints a long to the stream. The value printed is
determined using the
String.valueOf()
method.
This method prints a line termination sequence after printing the value.
lnum
- The long
value to be printed
setError
protected void setError()
This method can be called by subclasses to indicate that an error
has occurred and should be reported by checkError
.
write
public void write(byte[] buffer,
int offset,
int len)
This method writes len
bytes from the specified array
starting at index offset
into the array.
- write in interface FilterOutputStream
buffer
- The array of bytes to writeoffset
- The index into the array to start writing fromlen
- The number of bytes to write
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.
- write in interface FilterOutputStream
oneByte
- The byte to be written
PrintStream.java -- OutputStream for printing output
Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.