# PrintStream

public class **PrintStream** extends [FilterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html)  
implements [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) [Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html) 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 `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html` `` class should be used in situations that require writing
characters rather than bytes.

### Inherited Field Summary

From class [java.io.FilterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html)

|---|---|---|
| protected [OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) | [out](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#out) | The underlying output stream to be filtered. |

### Public Constructor Summary

|---|---|
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.io.OutputStream))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out) Creates a new print stream. |
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.io.OutputStream,%20boolean))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, boolean autoFlush) Creates a new print stream. |
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.io.OutputStream,%20boolean,%20java.lang.String))([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, boolean autoFlush, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) encoding) Creates a new print stream. |
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) fileName) Creates a new print stream, without automatic line flushing, with the specified file name. |
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.lang.String,%20java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) fileName, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) csn) Creates a new print stream, without automatic line flushing, with the specified file name and charset. |
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.io.File))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file) Creates a new print stream, without automatic line flushing, with the specified file. |
|   | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#PrintStream(java.io.File,%20java.lang.String))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) csn) Creates a new print stream, without automatic line flushing, with the specified file and charset. |

### Public Method Summary

|---|---|
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#append(char))(char c) Appends the specified character to this output stream. |
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#append(java.lang.CharSequence,%20int,%20int))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) csq, int start, int end) Appends a subsequence of the specified character sequence to this output stream. |
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#append(java.lang.CharSequence))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) csq) Appends the specified character sequence to this output stream. |
| boolean | [checkError](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#checkError())() Flushes the stream and checks its error state. |
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#close())() Closes the stream. |
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#flush())() Flushes the stream. |
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [format](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#format(java.util.Locale,%20java.lang.String,%20java.lang.Object...))([Locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) l, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) Writes a formatted string to this output stream using the specified format string and arguments. |
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [format](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#format(java.lang.String,%20java.lang.Object...))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) Writes a formatted string to this output stream using the specified format string and arguments. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(int))(int i) Prints an integer. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(double))(double d) Prints a double-precision floating-point number. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(boolean))(boolean b) Prints a boolean value. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(char))(char c) Prints a character. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(long))(long l) Prints a long integer. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(float))(float f) Prints a floating-point number. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s) Prints a string. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Prints an object. |
| void | [print](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(char[]))(char\[\] s) Prints an array of characters. |
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [printf](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#printf(java.lang.String,%20java.lang.Object...))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) A convenience method to write a formatted string to this output stream using the specified format string and arguments. |
| [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | [printf](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#printf(java.util.Locale,%20java.lang.String,%20java.lang.Object...))([Locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) l, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) A convenience method to write a formatted string to this output stream using the specified format string and arguments. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) x) Prints an Object and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(char))(char x) Prints a character and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(boolean))(boolean x) Prints a boolean and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(long))(long x) Prints a long and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println())() Terminates the current line by writing the line separator string. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(int))(int x) Prints an integer and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) x) Prints a String and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(char[]))(char\[\] x) Prints an array of characters and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(float))(float x) Prints a float and then terminate the line. |
| void | [println](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(double))(double x) Prints a double and then terminate the line. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(byte[],%20int,%20int))(byte\[\] buf, int off, int len) Writes `len` bytes from the specified byte array starting at offset `off` to this stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int))(int b) Writes the specified byte to this stream. |

### Protected Method Summary

|---|---|
| void | [clearError](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#clearError())() Clears the internal error state of this stream. |
| void | [setError](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#setError())() Sets the error state of the stream to `true`. |

### Inherited Method Summary

From class [java.io.FilterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html)

|---|---|
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#close())() Closes this output stream and releases any system resources associated with the stream. |
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#flush())() Flushes this output stream and forces any buffered output bytes to be written out to the stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(byte[]))(byte\[\] b) Writes `b.length` bytes to this output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(byte[],%20int,%20int))(byte\[\] b, int off, int len) Writes `len` bytes from the specified `byte` array starting at offset `off` to this output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html#write(int))(int b) Writes the specified `byte` to this output stream. |

From class [java.io.OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html)

|---|---|
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#close())() Closes this output stream and releases any system resources associated with this stream. |
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#flush())() Flushes this output stream and forces any buffered output bytes to be written out. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#write(byte[]))(byte\[\] b) Writes `b.length` bytes from the specified byte array to this output stream. |
| void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#write(byte[],%20int,%20int))(byte\[\] b, int off, int len) Writes `len` bytes from the specified byte array starting at offset `off` to this output stream. |
| abstract void | [write](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#write(int))(int b) Writes the specified byte to this output stream. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.io.Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

From interface [java.io.Flushable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html)

|---|---|
| abstract void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html#flush())() Flushes this stream by writing any buffered output to the underlying stream. |

From interface [java.lang.Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html)

|---|---|
| abstract [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html#append(char))(char c) Appends the specified character to this Appendable. |
| abstract [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html#append(java.lang.CharSequence,%20int,%20int))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) csq, int start, int end) Appends a subsequence of the specified character sequence to this Appendable. |
| abstract [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html#append(java.lang.CharSequence))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) csq) Appends the specified character sequence to this Appendable. |

From interface [java.lang.AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Public Constructors

#### public
**PrintStream**
([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out)

Creates 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

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html#PrintWriter(java.io.OutputStream)`

#### public
**PrintStream**
([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, boolean autoFlush)

Creates 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

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html#PrintWriter(java.io.OutputStream,%20boolean)`

#### public
**PrintStream**
([OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) out, boolean autoFlush, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) encoding)

Creates 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/package-summary.html#charenc) |
|---|---|

##### Throws

| [UnsupportedEncodingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/UnsupportedEncodingException.html) | If the named encoding is not supported |
|---|---|

#### public
**PrintStream**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) fileName)

Creates a new print stream, without automatic line flushing, with the
specified file name. This convenience constructor creates
the necessary intermediate `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStreamWriter.html`, which will encode characters using the
{@linkplain java.nio.charset.Charset#defaultCharset() default charset}
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](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileNotFoundException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager is present and `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkWrite(java.io.FileDescriptor)` denies write access to the file |
|---|---|

#### public
**PrintStream**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) fileName, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) csn)

Creates a new print stream, without automatic line flushing, with the
specified file name and charset. This convenience constructor creates
the necessary intermediate `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStreamWriter.html`, 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 {@linkplain java.nio.charset.Charset charset} |
|---|---|

##### Throws

| [FileNotFoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileNotFoundException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager is present and `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkWrite(java.io.FileDescriptor)` denies write access to the file |
| [UnsupportedEncodingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/UnsupportedEncodingException.html) | If the named charset is not supported |
|---|---|

#### public
**PrintStream**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file)

Creates a new print stream, without automatic line flushing, with the
specified file. This convenience constructor creates the necessary
intermediate `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStreamWriter.html`,
which will encode characters using the {@linkplain java.nio.charset.Charset#defaultCharset() default charset} 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileNotFoundException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager is present and `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkWrite(java.io.FileDescriptor)` denies write access to the file |
|---|---|

#### public
**PrintStream**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) csn)

Creates a new print stream, without automatic line flushing, with the
specified file and charset. This convenience constructor creates
the necessary intermediate `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStreamWriter.html`, 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 {@linkplain java.nio.charset.Charset charset} |
|---|---|

##### Throws

| [FileNotFoundException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileNotFoundException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | If a security manager is present and `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkWrite(java.io.FileDescriptor)` denies write access to the file |
| [UnsupportedEncodingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/UnsupportedEncodingException.html) | If the named charset is not supported |
|---|---|

## Public Methods

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**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) 
```

<br />

##### Parameters

| c | The 16-bit character to append |
|---|---|

##### Returns

- This output stream

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**append**
([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) 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()) 
```

<br />

##### 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 output stream

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) | If start or end are negative, start is greater than end, or end is greater than csq.length() |
|---|---|

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**append**
([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) 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. For instance, invoking then toString method of a
character buffer will return a subsequence whose content depends upon
the buffer's position and limit.

##### Parameters

| csq | The character sequence to append. If csq is null, then the four characters "null" are appended to this output stream. |
|---|---|

##### Returns

- This output stream

#### public boolean
**checkError**
()

Flushes the stream and checks 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.

<br />

##### Returns

- `true` if and only if this stream has encountered an `IOException` other than `InterruptedIOException`, or the `setError` method has been invoked

#### public void
**close**
()

Closes the stream. This is done by flushing the stream and then closing
the underlying output stream.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#close()`

#### public void
**flush**
()

Flushes the stream. This is done by writing any buffered output bytes to
the underlying output stream and then flushing that stream.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html#flush()`

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**format**
([Locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) l, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args)

Writes a formatted string to this output stream using the specified
format string and arguments.

##### Parameters

| l | The {@linkplain java.util.Locale locale} to apply during formatting. If l is null then no localization is applied. |
| format | A format string as described in [Format string syntax](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#syntax). |
|---|---|

##### Returns

- This output stream

##### Throws

| [IllegalFormatException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/IllegalFormatException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#detail) section of the formatter class specification. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If the format is null |
|---|---|

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**format**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) 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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html#getDefault()`, regardless of any
previous invocations of other formatting methods on this object.

##### Parameters

| format | A format string as described in [Format string syntax](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#syntax). |
|---|---|

##### Returns

- This output stream

##### Throws

| [IllegalFormatException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/IllegalFormatException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#detail) section of the formatter class specification. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If the format is null |
|---|---|

#### public void
**print**
(int i)

Prints an integer. The string produced by `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html#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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| i | The `int` to be printed |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Integer.html#toString(int)`

#### public void
**print**
(double d)

Prints a double-precision floating-point number. The string produced by
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html#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 `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| d | The `double` to be printed |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Double.html#toString(double)`

#### public void
**print**
(boolean b)

Prints a boolean value. The string produced by `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html#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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| b | The `boolean` to be printed |
|---|---|

#### public void
**print**
(char c)

Prints 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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| c | The `char` to be printed |
|---|---|

#### public void
**print**
(long l)

Prints a long integer. The string produced by `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html#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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| l | The `long` to be printed |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Long.html#toString(long)`

#### public void
**print**
(float f)

Prints a floating-point number. The string produced by `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html#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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| f | The `float` to be printed |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Float.html#toString(float)`

#### public void
**print**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s)

Prints 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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| s | The `String` to be printed |
|---|---|

#### public void
**print**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj)

Prints an object. The string produced by the `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html#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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| obj | The `Object` to be printed |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString()`

#### public void
**print**
(char\[\] s)

Prints 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
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#write(int)` `` method.

##### Parameters

| s | The array of chars to be printed |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If `s` is `null` |
|---|---|

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**printf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) 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) 
```

<br />

##### Parameters

| format | A format string as described in [Format string syntax](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#syntax). |
|---|---|

##### Returns

- This output stream

##### Throws

| [IllegalFormatException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/IllegalFormatException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#detail) section of the formatter class specification. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If the format is null |
|---|---|

#### public [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html)
**printf**
([Locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) l, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) 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) 
```

<br />

##### Parameters

| l | The {@linkplain java.util.Locale locale} to apply during formatting. If l is null then no localization is applied. |
| format | A format string as described in [Format string syntax](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#syntax). |
|---|---|

##### Returns

- This output stream

##### Throws

| [IllegalFormatException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/IllegalFormatException.html) | 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](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#detail) section of the formatter class specification. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If the format is null |
|---|---|

#### public void
**println**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) x)

Prints an Object and then terminate the line. This method calls
at first String.valueOf(x) to get the printed object's string value,
then behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(java.lang.String)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `Object` to be printed. |
|---|---|

#### public void
**println**
(char x)

Prints a character and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(char)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `char` to be printed. |
|---|---|

#### public void
**println**
(boolean x)

Prints a boolean and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(boolean)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `boolean` to be printed |
|---|---|

#### public void
**println**
(long x)

Prints a long and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(long)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | a The `long` to be printed. |
|---|---|

#### public void
**println**
()

Terminates 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'`).

#### public void
**println**
(int x)

Prints an integer and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(int)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `int` to be printed. |
|---|---|

#### public void
**println**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) x)

Prints a String and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(java.lang.String)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `String` to be printed. |
|---|---|

#### public void
**println**
(char\[\] x)

Prints an array of characters and then terminate the line. This method
behaves as though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(char[])` `` and
then `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | an array of chars to print. |
|---|---|

#### public void
**println**
(float x)

Prints a float and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(float)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `float` to be printed. |
|---|---|

#### public void
**println**
(double x)

Prints a double and then terminate the line. This method behaves as
though it invokes `` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(double)` `` and then
`` `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println()` ``.

##### Parameters

| x | The `double` to be printed. |
|---|---|

#### public void
**write**
(byte\[\] buf, int off, int len)

Writes `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.

##### Parameters

| buf | A byte array |
| off | Offset from which to start taking bytes |
| len | Number of bytes to write |
|---|---|

#### public void
**write**
(int b)

Writes 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.

##### Parameters

| b | The byte to be written |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#print(char)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#println(char)`

## Protected Methods

#### protected void
**clearError**
()

Clears the internal error state of this stream.

This method will cause subsequent invocations of `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#checkError()` to return false until another write
operation fails and invokes `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#setError()`.

#### protected void
**setError**
()

Sets the error state of the stream to `true`.

This method will cause subsequent invocations of `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#checkError()` to return true until `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html#clearError()` is invoked.