java.io
Class PrintStream

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.io.OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream 
      extended by java.io.FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream 
          extended by java.io.PrintStream
All Implemented Interfaces:
Closeable sample code for java.io.Closeable definition code for java.io.Closeable , Flushable sample code for java.io.Flushable definition code for java.io.Flushable , Appendable sample code for java.lang.Appendable definition code for java.lang.Appendable
Direct Known Subclasses:
LogStream sample code for java.rmi.server.LogStream definition code for java.rmi.server.LogStream

public class PrintStream
extends FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
implements Appendable sample code for java.lang.Appendable definition code for java.lang.Appendable , Closeable sample code for java.io.Closeable definition code for java.io.Closeable

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. Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.

All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. The PrintWriter sample code for java.io.PrintWriter definition code for java.io.PrintWriter class should be used in situations that require writing characters rather than bytes.

Since:
JDK1.0

Field Summary
 
Fields inherited from class java.io.FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
out sample code for java.io.FilterOutputStream.out definition code for java.io.FilterOutputStream.out
 
Constructor Summary
PrintStream sample code for java.io.PrintStream.PrintStream(java.io.File) definition code for java.io.PrintStream.PrintStream(java.io.File) (File sample code for java.io.File definition code for java.io.File  file)
          Creates a new print stream, without automatic line flushing, with the specified file.
PrintStream sample code for java.io.PrintStream.PrintStream(java.io.File, java.lang.String) definition code for java.io.PrintStream.PrintStream(java.io.File, java.lang.String) (File sample code for java.io.File definition code for java.io.File  file, String sample code for java.lang.String definition code for java.lang.String  csn)
          Creates a new print stream, without automatic line flushing, with the specified file and charset.
PrintStream sample code for java.io.PrintStream.PrintStream(java.io.OutputStream) definition code for java.io.PrintStream.PrintStream(java.io.OutputStream) (OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  out)
          Create a new print stream.
PrintStream sample code for java.io.PrintStream.PrintStream(java.io.OutputStream, boolean) definition code for java.io.PrintStream.PrintStream(java.io.OutputStream, boolean) (OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  out, boolean autoFlush)
          Create a new print stream.
PrintStream sample code for java.io.PrintStream.PrintStream(java.io.OutputStream, boolean, java.lang.String) definition code for java.io.PrintStream.PrintStream(java.io.OutputStream, boolean, java.lang.String) (OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  out, boolean autoFlush, String sample code for java.lang.String definition code for java.lang.String  encoding)
          Create a new print stream.
PrintStream sample code for java.io.PrintStream.PrintStream(java.lang.String) definition code for java.io.PrintStream.PrintStream(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  fileName)
          Creates a new print stream, without automatic line flushing, with the specified file name.
PrintStream sample code for java.io.PrintStream.PrintStream(java.lang.String, java.lang.String) definition code for java.io.PrintStream.PrintStream(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  fileName, String sample code for java.lang.String definition code for java.lang.String  csn)
          Creates a new print stream, without automatic line flushing, with the specified file name and charset.
 
Method Summary
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream append sample code for java.io.PrintStream.append(char) definition code for java.io.PrintStream.append(char) (char c)
          Appends the specified character to this output stream.
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream append sample code for java.io.PrintStream.append(java.lang.CharSequence) definition code for java.io.PrintStream.append(java.lang.CharSequence) (CharSequence sample code for java.lang.CharSequence definition code for java.lang.CharSequence  csq)
          Appends the specified character sequence to this output stream.
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream append sample code for java.io.PrintStream.append(java.lang.CharSequence, int, int) definition code for java.io.PrintStream.append(java.lang.CharSequence, int, int) (CharSequence sample code for java.lang.CharSequence definition code for java.lang.CharSequence  csq, int start, int end)
          Appends a subsequence of the specified character sequence to this output stream.
 boolean checkError sample code for java.io.PrintStream.checkError() definition code for java.io.PrintStream.checkError() ()
          Flush the stream and check its error state.
 void close sample code for java.io.PrintStream.close() definition code for java.io.PrintStream.close() ()
          Close the stream.
 void flush sample code for java.io.PrintStream.flush() definition code for java.io.PrintStream.flush() ()
          Flush the stream.
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream format sample code for java.io.PrintStream.format(java.util.Locale, java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.format(java.util.Locale, java.lang.String, java.lang.Object...) (Locale sample code for java.util.Locale definition code for java.util.Locale  l, String sample code for java.lang.String definition code for java.lang.String  format, Object sample code for java.lang.Object definition code for java.lang.Object ... args)
          Writes a formatted string to this output stream using the specified format string and arguments.
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream format sample code for java.io.PrintStream.format(java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.format(java.lang.String, java.lang.Object...) (String sample code for java.lang.String definition code for java.lang.String  format, Object sample code for java.lang.Object definition code for java.lang.Object ... args)
          Writes a formatted string to this output stream using the specified format string and arguments.
 void print sample code for java.io.PrintStream.print(boolean) definition code for java.io.PrintStream.print(boolean) (boolean b)
          Print a boolean value.
 void print sample code for java.io.PrintStream.print(char) definition code for java.io.PrintStream.print(char) (char c)
          Print a character.
 void print sample code for java.io.PrintStream.print(char[]) definition code for java.io.PrintStream.print(char[]) (char[] s)
          Print an array of characters.
 void print sample code for java.io.PrintStream.print(double) definition code for java.io.PrintStream.print(double) (double d)
          Print a double-precision floating-point number.
 void print sample code for java.io.PrintStream.print(float) definition code for java.io.PrintStream.print(float) (float f)
          Print a floating-point number.
 void print sample code for java.io.PrintStream.print(int) definition code for java.io.PrintStream.print(int) (int i)
          Print an integer.
 void print sample code for java.io.PrintStream.print(long) definition code for java.io.PrintStream.print(long) (long l)
          Print a long integer.
 void print sample code for java.io.PrintStream.print(java.lang.Object) definition code for java.io.PrintStream.print(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Print an object.
 void print sample code for java.io.PrintStream.print(java.lang.String) definition code for java.io.PrintStream.print(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  s)
          Print a string.
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream printf sample code for java.io.PrintStream.printf(java.util.Locale, java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.printf(java.util.Locale, java.lang.String, java.lang.Object...) (Locale sample code for java.util.Locale definition code for java.util.Locale  l, String sample code for java.lang.String definition code for java.lang.String  format, Object sample code for java.lang.Object definition code for java.lang.Object ... args)
          A convenience method to write a formatted string to this output stream using the specified format string and arguments.
 PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream printf sample code for java.io.PrintStream.printf(java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.printf(java.lang.String, java.lang.Object...) (String sample code for java.lang.String definition code for java.lang.String  format, Object sample code for java.lang.Object definition code for java.lang.Object ... args)
          A convenience method to write a formatted string to this output stream using the specified format string and arguments.
 void println sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() ()
          Terminate the current line by writing the line separator string.
 void println sample code for java.io.PrintStream.println(boolean) definition code for java.io.PrintStream.println(boolean) (boolean x)
          Print a boolean and then terminate the line.
 void println sample code for java.io.PrintStream.println(char) definition code for java.io.PrintStream.println(char) (char x)
          Print a character and then terminate the line.
 void println sample code for java.io.PrintStream.println(char[]) definition code for java.io.PrintStream.println(char[]) (char[] x)
          Print an array of characters and then terminate the line.
 void println sample code for java.io.PrintStream.println(double) definition code for java.io.PrintStream.println(double) (double x)
          Print a double and then terminate the line.
 void println sample code for java.io.PrintStream.println(float) definition code for java.io.PrintStream.println(float) (float x)
          Print a float and then terminate the line.
 void println sample code for java.io.PrintStream.println(int) definition code for java.io.PrintStream.println(int) (int x)
          Print an integer and then terminate the line.
 void println sample code for java.io.PrintStream.println(long) definition code for java.io.PrintStream.println(long) (long x)
          Print a long and then terminate the line.
 void println sample code for java.io.PrintStream.println(java.lang.Object) definition code for java.io.PrintStream.println(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  x)
          Print an Object and then terminate the line.
 void println sample code for java.io.PrintStream.println(java.lang.String) definition code for java.io.PrintStream.println(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  x)
          Print a String and then terminate the line.
protected  void setError sample code for java.io.PrintStream.setError() definition code for java.io.PrintStream.setError() ()
          Set the error state of the stream to true.
 void write sample code for java.io.PrintStream.write(byte[], int, int) definition code for java.io.PrintStream.write(byte[], int, int) (byte[] buf, int off, int len)
          Write len bytes from the specified byte array starting at offset off to this stream.
 void write sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) (int b)
          Write the specified byte to this stream.
 
Methods inherited from class java.io.FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
write sample code for java.io.FilterOutputStream.write(byte[]) definition code for java.io.FilterOutputStream.write(byte[])
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

PrintStream sample code for java.io.PrintStream(java.io.OutputStream) definition code for java.io.PrintStream(java.io.OutputStream)

public PrintStream(OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  out)
Create a new print stream. This stream will not flush automatically.

Parameters:
out - The output stream to which values and objects will be printed
See Also:
PrintWriter.PrintWriter(java.io.OutputStream) sample code for java.io.PrintWriter.PrintWriter(java.io.OutputStream) definition code for java.io.PrintWriter.PrintWriter(java.io.OutputStream)

PrintStream sample code for java.io.PrintStream(java.io.OutputStream, boolean) definition code for java.io.PrintStream(java.io.OutputStream, boolean)

public PrintStream(OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  out,
                   boolean autoFlush)
Create a new print stream.

Parameters:
out - The output stream to which values and objects will be printed
autoFlush - A boolean; if true, the output buffer will be flushed whenever a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written
See Also:
PrintWriter.PrintWriter(java.io.OutputStream, boolean) sample code for java.io.PrintWriter.PrintWriter(java.io.OutputStream, boolean) definition code for java.io.PrintWriter.PrintWriter(java.io.OutputStream, boolean)

PrintStream sample code for java.io.PrintStream(java.io.OutputStream, boolean, java.lang.String) definition code for java.io.PrintStream(java.io.OutputStream, boolean, java.lang.String)

public PrintStream(OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  out,
                   boolean autoFlush,
                   String sample code for java.lang.String definition code for java.lang.String  encoding)
            throws UnsupportedEncodingException sample code for java.io.UnsupportedEncodingException definition code for java.io.UnsupportedEncodingException 
Create a new print stream.

Parameters:
out - The output stream to which values and objects will be printed
autoFlush - A boolean; if true, the output buffer will be flushed whenever a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written
encoding - The name of a supported character encoding
Throws:
UnsupportedEncodingException sample code for java.io.UnsupportedEncodingException definition code for java.io.UnsupportedEncodingException - If the named encoding is not supported

PrintStream sample code for java.io.PrintStream(java.lang.String) definition code for java.io.PrintStream(java.lang.String)

public PrintStream(String sample code for java.lang.String definition code for java.lang.String  fileName)
            throws FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException 
Creates a new print stream, without automatic line flushing, with the specified file name. This convenience constructor creates the necessary intermediate OutputStreamWriter sample code for java.io.OutputStreamWriter definition code for java.io.OutputStreamWriter , which will encode characters using the default charset sample code for java.nio.charset.Charset.defaultCharset definition code for java.nio.charset.Charset.defaultCharset for this instance of the Java virtual machine.

Parameters:
fileName - The name of the file to use as the destination of this print stream. If the file exists, then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
Throws:
FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is present and checkWrite(fileName) sample code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) definition code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) denies write access to the file
Since:
1.5

PrintStream sample code for java.io.PrintStream(java.lang.String, java.lang.String) definition code for java.io.PrintStream(java.lang.String, java.lang.String)

public PrintStream(String sample code for java.lang.String definition code for java.lang.String  fileName,
                   String sample code for java.lang.String definition code for java.lang.String  csn)
            throws FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException ,
                   UnsupportedEncodingException sample code for java.io.UnsupportedEncodingException definition code for java.io.UnsupportedEncodingException 
Creates a new print stream, without automatic line flushing, with the specified file name and charset. This convenience constructor creates the necessary intermediate OutputStreamWriter sample code for java.io.OutputStreamWriter definition code for java.io.OutputStreamWriter , which will encode characters using the provided charset.

Parameters:
fileName - The name of the file to use as the destination of this print stream. If the file exists, then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
csn - The name of a supported charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset
Throws:
FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is present and checkWrite(fileName) sample code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) definition code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) denies write access to the file
UnsupportedEncodingException sample code for java.io.UnsupportedEncodingException definition code for java.io.UnsupportedEncodingException - If the named charset is not supported
Since:
1.5

PrintStream sample code for java.io.PrintStream(java.io.File) definition code for java.io.PrintStream(java.io.File)

public PrintStream(File sample code for java.io.File definition code for java.io.File  file)
            throws FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException 
Creates a new print stream, without automatic line flushing, with the specified file. This convenience constructor creates the necessary intermediate OutputStreamWriter sample code for java.io.OutputStreamWriter definition code for java.io.OutputStreamWriter , which will encode characters using the default charset sample code for java.nio.charset.Charset.defaultCharset definition code for java.nio.charset.Charset.defaultCharset for this instance of the Java virtual machine.

Parameters:
file - The file to use as the destination of this print stream. If the file exists, then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
Throws:
FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is present and checkWrite(file.getPath()) sample code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) definition code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) denies write access to the file
Since:
1.5

PrintStream sample code for java.io.PrintStream(java.io.File, java.lang.String) definition code for java.io.PrintStream(java.io.File, java.lang.String)

public PrintStream(File sample code for java.io.File definition code for java.io.File  file,
                   String sample code for java.lang.String definition code for java.lang.String  csn)
            throws FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException ,
                   UnsupportedEncodingException sample code for java.io.UnsupportedEncodingException definition code for java.io.UnsupportedEncodingException 
Creates a new print stream, without automatic line flushing, with the specified file and charset. This convenience constructor creates the necessary intermediate OutputStreamWriter sample code for java.io.OutputStreamWriter definition code for java.io.OutputStreamWriter , which will encode characters using the provided charset.

Parameters:
file - The file to use as the destination of this print stream. If the file exists, then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
csn - The name of a supported charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset
Throws:
FileNotFoundException sample code for java.io.FileNotFoundException definition code for java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager is presentand checkWrite(file.getPath()) sample code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) definition code for java.lang.SecurityManager.checkWrite(java.io.FileDescriptor) denies write access to the file
UnsupportedEncodingException sample code for java.io.UnsupportedEncodingException definition code for java.io.UnsupportedEncodingException - If the named charset is not supported
Since:
1.5
Method Detail

flush sample code for java.io.PrintStream.flush() definition code for java.io.PrintStream.flush()

public void flush()
Flush the stream. This is done by writing any buffered output bytes to the underlying output stream and then flushing that stream.

Specified by:
flush sample code for java.io.Flushable.flush() definition code for java.io.Flushable.flush() in interface Flushable sample code for java.io.Flushable definition code for java.io.Flushable
Overrides:
flush sample code for java.io.FilterOutputStream.flush() definition code for java.io.FilterOutputStream.flush() in class FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
See Also:
OutputStream.flush() sample code for java.io.OutputStream.flush() definition code for java.io.OutputStream.flush()

close sample code for java.io.PrintStream.close() definition code for java.io.PrintStream.close()

public void close()
Close the stream. This is done by flushing the stream and then closing the underlying output stream.

Specified by:
close sample code for java.io.Closeable.close() definition code for java.io.Closeable.close() in interface Closeable sample code for java.io.Closeable definition code for java.io.Closeable
Overrides:
close sample code for java.io.FilterOutputStream.close() definition code for java.io.FilterOutputStream.close() in class FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
See Also:
OutputStream.close() sample code for java.io.OutputStream.close() definition code for java.io.OutputStream.close()

checkError sample code for java.io.PrintStream.checkError() definition code for java.io.PrintStream.checkError()

public boolean checkError()
Flush the stream and check its error state. The internal error state is set to true when the underlying output stream throws an IOException other than InterruptedIOException, and when the setError method is invoked. If an operation on the underlying output stream throws an InterruptedIOException, then the PrintStream converts the exception back into an interrupt by doing:
     Thread.currentThread().interrupt();
 
or the equivalent.

Returns:
True if and only if this stream has encountered an IOException other than InterruptedIOException, or the setError method has been invoked

setError sample code for java.io.PrintStream.setError() definition code for java.io.PrintStream.setError()

protected void setError()
Set the error state of the stream to true.

Since:
JDK1.1

write sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int)

public void write(int b)
Write the specified byte to this stream. If the byte is a newline and automatic flushing is enabled then the flush method will be invoked.

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 sample code for java.io.FilterOutputStream.write(int) definition code for java.io.FilterOutputStream.write(int) in class FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
Parameters:
b - The byte to be written
See Also:
print(char) sample code for java.io.PrintStream.print(char) definition code for java.io.PrintStream.print(char) , println(char) sample code for java.io.PrintStream.println(char) definition code for java.io.PrintStream.println(char)

write sample code for java.io.PrintStream.write(byte[], int, int) definition code for java.io.PrintStream.write(byte[], int, int)

public void write(byte[] buf,
                  int off,
                  int len)
Write len bytes from the specified byte array starting at offset off to this stream. If automatic flushing is enabled then the flush method will be invoked.

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 sample code for java.io.FilterOutputStream.write(byte[], int, int) definition code for java.io.FilterOutputStream.write(byte[], int, int) in class FilterOutputStream sample code for java.io.FilterOutputStream definition code for java.io.FilterOutputStream
Parameters:
buf - A byte array
off - Offset from which to start taking bytes
len - Number of bytes to write
See Also:
FilterOutputStream.write(int) sample code for java.io.FilterOutputStream.write(int) definition code for java.io.FilterOutputStream.write(int)

print sample code for java.io.PrintStream.print(boolean) definition code for java.io.PrintStream.print(boolean)

public void print(boolean b)
Print a boolean value. The string produced by String.valueOf(boolean) sample code for java.lang.String.valueOf(boolean) definition code for 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) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
b - The boolean to be printed

print sample code for java.io.PrintStream.print(char) definition code for java.io.PrintStream.print(char)

public void print(char c)
Print a character. The character is translated into one or more bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
c - The char to be printed

print sample code for java.io.PrintStream.print(int) definition code for java.io.PrintStream.print(int)

public void print(int i)
Print an integer. The string produced by String.valueOf(int) sample code for java.lang.String.valueOf(int) definition code for java.lang.String.valueOf(int) 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) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
i - The int to be printed
See Also:
Integer.toString(int) sample code for java.lang.Integer.toString(int) definition code for java.lang.Integer.toString(int)

print sample code for java.io.PrintStream.print(long) definition code for java.io.PrintStream.print(long)

public void print(long l)
Print a long integer. The string produced by String.valueOf(long) sample code for java.lang.String.valueOf(long) definition code for java.lang.String.valueOf(long) 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) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
l - The long to be printed
See Also:
Long.toString(long) sample code for java.lang.Long.toString(long) definition code for java.lang.Long.toString(long)

print sample code for java.io.PrintStream.print(float) definition code for java.io.PrintStream.print(float)

public void print(float f)
Print a floating-point number. The string produced by String.valueOf(float) sample code for java.lang.String.valueOf(float) definition code for java.lang.String.valueOf(float) 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) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
f - The float to be printed
See Also:
Float.toString(float) sample code for java.lang.Float.toString(float) definition code for java.lang.Float.toString(float)

print sample code for java.io.PrintStream.print(double) definition code for java.io.PrintStream.print(double)

public void print(double d)
Print a double-precision floating-point number. The string produced by String.valueOf(double) sample code for java.lang.String.valueOf(double) definition code for java.lang.String.valueOf(double) 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) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
d - The double to be printed
See Also:
Double.toString(double) sample code for java.lang.Double.toString(double) definition code for java.lang.Double.toString(double)

print sample code for java.io.PrintStream.print(char[]) definition code for java.io.PrintStream.print(char[])

public void print(char[] s)
Print an array of characters. The characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
s - The array of chars to be printed
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - If s is null

print sample code for java.io.PrintStream.print(java.lang.String) definition code for java.io.PrintStream.print(java.lang.String)

public void print(String sample code for java.lang.String definition code for java.lang.String  s)
Print a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
s - The String to be printed

print sample code for java.io.PrintStream.print(java.lang.Object) definition code for java.io.PrintStream.print(java.lang.Object)

public void print(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Print an object. The string produced by the String.valueOf(Object) sample code for java.lang.String.valueOf(java.lang.Object) definition code for java.lang.String.valueOf(java.lang.Object) method 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) sample code for java.io.PrintStream.write(int) definition code for java.io.PrintStream.write(int) method.

Parameters:
obj - The Object to be printed
See Also:
Object.toString() sample code for java.lang.Object.toString() definition code for java.lang.Object.toString()

println sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println()

public void println()
Terminate the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').


println sample code for java.io.PrintStream.println(boolean) definition code for java.io.PrintStream.println(boolean)

public void println(boolean x)
Print a boolean and then terminate the line. This method behaves as though it invokes print(boolean) sample code for java.io.PrintStream.print(boolean) definition code for java.io.PrintStream.print(boolean) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The boolean to be printed

println sample code for java.io.PrintStream.println(char) definition code for java.io.PrintStream.println(char)

public void println(char x)
Print a character and then terminate the line. This method behaves as though it invokes print(char) sample code for java.io.PrintStream.print(char) definition code for java.io.PrintStream.print(char) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The char to be printed.

println sample code for java.io.PrintStream.println(int) definition code for java.io.PrintStream.println(int)

public void println(int x)
Print an integer and then terminate the line. This method behaves as though it invokes print(int) sample code for java.io.PrintStream.print(int) definition code for java.io.PrintStream.print(int) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The int to be printed.

println sample code for java.io.PrintStream.println(long) definition code for java.io.PrintStream.println(long)

public void println(long x)
Print a long and then terminate the line. This method behaves as though it invokes print(long) sample code for java.io.PrintStream.print(long) definition code for java.io.PrintStream.print(long) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - a The long to be printed.

println sample code for java.io.PrintStream.println(float) definition code for java.io.PrintStream.println(float)

public void println(float x)
Print a float and then terminate the line. This method behaves as though it invokes print(float) sample code for java.io.PrintStream.print(float) definition code for java.io.PrintStream.print(float) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The float to be printed.

println sample code for java.io.PrintStream.println(double) definition code for java.io.PrintStream.println(double)

public void println(double x)
Print a double and then terminate the line. This method behaves as though it invokes print(double) sample code for java.io.PrintStream.print(double) definition code for java.io.PrintStream.print(double) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The double to be printed.

println sample code for java.io.PrintStream.println(char[]) definition code for java.io.PrintStream.println(char[])

public void println(char[] x)
Print an array of characters and then terminate the line. This method behaves as though it invokes print(char[]) sample code for java.io.PrintStream.print(char[]) definition code for java.io.PrintStream.print(char[]) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - an array of chars to print.

println sample code for java.io.PrintStream.println(java.lang.String) definition code for java.io.PrintStream.println(java.lang.String)

public void println(String sample code for java.lang.String definition code for java.lang.String  x)
Print a String and then terminate the line. This method behaves as though it invokes print(String) sample code for java.io.PrintStream.print(java.lang.String) definition code for java.io.PrintStream.print(java.lang.String) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The String to be printed.

println sample code for java.io.PrintStream.println(java.lang.Object) definition code for java.io.PrintStream.println(java.lang.Object)

public void println(Object sample code for java.lang.Object definition code for java.lang.Object  x)
Print an Object and then terminate the line. This method behaves as though it invokes print(Object) sample code for java.io.PrintStream.print(java.lang.Object) definition code for java.io.PrintStream.print(java.lang.Object) and then println() sample code for java.io.PrintStream.println() definition code for java.io.PrintStream.println() .

Parameters:
x - The Object to be printed.

printf sample code for java.io.PrintStream.printf(java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.printf(java.lang.String, java.lang.Object...)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  printf(String sample code for java.lang.String definition code for java.lang.String  format,
                          Object sample code for java.lang.Object definition code for java.lang.Object ... args)
A convenience method to write a formatted string to this output stream using the specified format string and arguments.

An invocation of this method of the form out.printf(format, args) behaves in exactly the same way as the invocation

     out.format(format, args) 

Parameters:
format - A format string as described in Format string syntax
args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
Returns:
This output stream
Throws:
IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - If the format is null
Since:
1.5

printf sample code for java.io.PrintStream.printf(java.util.Locale, java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.printf(java.util.Locale, java.lang.String, java.lang.Object...)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  printf(Locale sample code for java.util.Locale definition code for java.util.Locale  l,
                          String sample code for java.lang.String definition code for java.lang.String  format,
                          Object sample code for java.lang.Object definition code for java.lang.Object ... args)
A convenience method to write a formatted string to this output stream using the specified format string and arguments.

An invocation of this method of the form out.printf(l, format, args) behaves in exactly the same way as the invocation

     out.format(l, format, args) 

Parameters:
l - The locale sample code for java.util.Locale definition code for java.util.Locale to apply during formatting. If l is null then no localization is applied.
format - A format string as described in Format string syntax
args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
Returns:
This output stream
Throws:
IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - If the format is null
Since:
1.5

format sample code for java.io.PrintStream.format(java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.format(java.lang.String, java.lang.Object...)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  format(String sample code for java.lang.String definition code for java.lang.String  format,
                          Object sample code for java.lang.Object definition code for java.lang.Object ... args)
Writes a formatted string to this output stream using the specified format string and arguments.

The locale always used is the one returned by Locale.getDefault() sample code for java.util.Locale.getDefault() definition code for java.util.Locale.getDefault() , regardless of any previous invocations of other formatting methods on this object.

Parameters:
format - A format string as described in Format string syntax
args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
Returns:
This output stream
Throws:
IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - If the format is null
Since:
1.5

format sample code for java.io.PrintStream.format(java.util.Locale, java.lang.String, java.lang.Object...) definition code for java.io.PrintStream.format(java.util.Locale, java.lang.String, java.lang.Object...)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  format(Locale sample code for java.util.Locale definition code for java.util.Locale  l,
                          String sample code for java.lang.String definition code for java.lang.String  format,
                          Object sample code for java.lang.Object definition code for java.lang.Object ... args)
Writes a formatted string to this output stream using the specified format string and arguments.

Parameters:
l - The locale sample code for java.util.Locale definition code for java.util.Locale to apply during formatting. If l is null then no localization is applied.
format - A format string as described in Format string syntax
args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
Returns:
This output stream
Throws:
IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - If the format is null
Since:
1.5

append sample code for java.io.PrintStream.append(java.lang.CharSequence) definition code for java.io.PrintStream.append(java.lang.CharSequence)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  append(CharSequence sample code for java.lang.CharSequence definition code for java.lang.CharSequence  csq)
Appends the specified character sequence to this output stream.

An invocation of this method of the form out.append(csq) behaves in exactly the same way as the invocation

     out.print(csq.toString()) 

Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. appended. For instance, invoking then toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

Specified by:
append sample code for java.lang.Appendable.append(java.lang.CharSequence) definition code for java.lang.Appendable.append(java.lang.CharSequence) in interface Appendable sample code for java.lang.Appendable definition code for java.lang.Appendable
Parameters:
csq - The character sequence to append. If csq is null, then the four characters "null" are appended to this output stream.
Returns:
This character stream
Since:
1.5

append sample code for java.io.PrintStream.append(java.lang.CharSequence, int, int) definition code for java.io.PrintStream.append(java.lang.CharSequence, int, int)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  append(CharSequence sample code for java.lang.CharSequence definition code for java.lang.CharSequence  csq,
                          int start,
                          int end)
Appends a subsequence of the specified character sequence to this output stream.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

     out.print(csq.subSequence(start, end).toString()) 

Specified by:
append sample code for java.lang.Appendable.append(java.lang.CharSequence, int, int) definition code for java.lang.Appendable.append(java.lang.CharSequence, int, int) in interface Appendable sample code for java.lang.Appendable definition code for java.lang.Appendable
Parameters:
csq - The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
start - The index of the first character in the subsequence
end - The index of the character following the last character in the subsequence
Returns:
This character stream
Throws:
IndexOutOfBoundsException sample code for java.lang.IndexOutOfBoundsException definition code for java.lang.IndexOutOfBoundsException - If start or end are negative, start is greater than end, or end is greater than csq.length()
Since:
1.5

append sample code for java.io.PrintStream.append(char) definition code for java.io.PrintStream.append(char)

public PrintStream sample code for java.io.PrintStream definition code for java.io.PrintStream  append(char c)
Appends the specified character to this output stream.

An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation

     out.print(c) 

Specified by:
append sample code for java.lang.Appendable.append(char) definition code for java.lang.Appendable.append(char) in interface Appendable sample code for java.lang.Appendable definition code for java.lang.Appendable
Parameters:
c - The 16-bit character to append
Returns:
This output stream
Since:
1.5