Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Fields](https://developer.android.com/reference/java/io/PrintStream#inhfields) \| [Ctors](https://developer.android.com/reference/java/io/PrintStream#pubctors) \| [Methods](https://developer.android.com/reference/java/io/PrintStream#pubmethods) \| [Protected Methods](https://developer.android.com/reference/java/io/PrintStream#promethods) \| [Inherited Methods](https://developer.android.com/reference/java/io/PrintStream#inhmethods)

# PrintStream


`
public


class
PrintStream
`


`


`

`


`

`

extends https://developer.android.com/reference/java/io/FilterOutputStream


`

`


implements

https://developer.android.com/reference/java/lang/Appendable,

https://developer.android.com/reference/java/io/Closeable


`

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||||
| ↳ | [java.io.OutputStream](https://developer.android.com/reference/java/io/OutputStream) |||
|   | ↳ | [java.io.FilterOutputStream](https://developer.android.com/reference/java/io/FilterOutputStream) ||
|   |   | ↳ | java.io.PrintStream |

<br />

*** ** * ** ***

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 of the underlying
output stream 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 given encoding or charset, or the platform's default
character encoding if not specified.
The `https://developer.android.com/reference/java/io/PrintWriter` class should be used in situations that require
writing characters rather than bytes.

This class always replaces malformed and unmappable character sequences
with the charset's default replacement string.
The [CharsetEncoder](https://developer.android.com/reference/java/nio/charset/CharsetEncoder) class should be used when more
control over the encoding process is required.

## Summary

| ### Inherited fields |
|---|
| From class `https://developer.android.com/reference/java/io/FilterOutputStream` |---|---| | ` protected https://developer.android.com/reference/java/io/OutputStream` | `https://developer.android.com/reference/java/io/FilterOutputStream#out` The underlying output stream to be filtered. | |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.File)(https://developer.android.com/reference/java/io/File file) ` Creates a new print stream, without automatic line flushing, with the specified file. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.File,%20java.lang.String)(https://developer.android.com/reference/java/io/File file, https://developer.android.com/reference/java/lang/String csn) ` Creates a new print stream, without automatic line flushing, with the specified file and charset. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.File,%20java.nio.charset.Charset)(https://developer.android.com/reference/java/io/File file, https://developer.android.com/reference/java/nio/charset/Charset charset) ` Creates a new print stream, without automatic line flushing, with the specified file and charset. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.OutputStream)(https://developer.android.com/reference/java/io/OutputStream out) ` Creates a new print stream, without automatic line flushing, with the specified OutputStream. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.OutputStream,%20boolean)(https://developer.android.com/reference/java/io/OutputStream out, boolean autoFlush) ` Creates a new print stream, with the specified OutputStream and line flushing. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.OutputStream,%20boolean,%20java.lang.String)(https://developer.android.com/reference/java/io/OutputStream out, boolean autoFlush, https://developer.android.com/reference/java/lang/String encoding) ` Creates a new print stream, with the specified OutputStream, line flushing, and character encoding. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.io.OutputStream,%20boolean,%20java.nio.charset.Charset)(https://developer.android.com/reference/java/io/OutputStream out, boolean autoFlush, https://developer.android.com/reference/java/nio/charset/Charset charset) ` Creates a new print stream, with the specified OutputStream, line flushing and charset. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.lang.String)(https://developer.android.com/reference/java/lang/String fileName) ` Creates a new print stream, without automatic line flushing, with the specified file name. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String fileName, https://developer.android.com/reference/java/lang/String csn) ` Creates a new print stream, without automatic line flushing, with the specified file name and charset. |
| ` https://developer.android.com/reference/java/io/PrintStream#PrintStream(java.lang.String,%20java.nio.charset.Charset)(https://developer.android.com/reference/java/lang/String fileName, https://developer.android.com/reference/java/nio/charset/Charset charset) ` Creates a new print stream, without automatic line flushing, with the specified file name and charset. |

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

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/java/io/PrintStream#clearError()() ` Clears the internal error state of this stream. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintStream#setError()() ` Sets the error state of the stream to `true`. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/io/FilterOutputStream ` |---|---| | ` void` | ` https://developer.android.com/reference/java/io/FilterOutputStream#close()() ` Closes this output stream and releases any system resources associated with the stream. | | ` void` | ` https://developer.android.com/reference/java/io/FilterOutputStream#flush()() ` Flushes this output stream and forces any buffered output bytes to be written out to the stream. | | ` void` | ` https://developer.android.com/reference/java/io/FilterOutputStream#write(byte[])(byte[] b) ` Writes `b.length` bytes to this output stream. | | ` void` | ` https://developer.android.com/reference/java/io/FilterOutputStream#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` | ` https://developer.android.com/reference/java/io/FilterOutputStream#write(int)(int b) ` Writes the specified `byte` to this output stream. | ||
| From class ` https://developer.android.com/reference/java/io/OutputStream ` |---|---| | ` void` | ` https://developer.android.com/reference/java/io/OutputStream#close()() ` Closes this output stream and releases any system resources associated with this stream. | | ` void` | ` https://developer.android.com/reference/java/io/OutputStream#flush()() ` Flushes this output stream and forces any buffered output bytes to be written out. | | ` static https://developer.android.com/reference/java/io/OutputStream` | ` https://developer.android.com/reference/java/io/OutputStream#nullOutputStream()() ` Returns a new `OutputStream` which discards all bytes. | | ` void` | ` https://developer.android.com/reference/java/io/OutputStream#write(byte[])(byte[] b) ` Writes `b.length` bytes from the specified byte array to this output stream. | | ` void` | ` https://developer.android.com/reference/java/io/OutputStream#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` | ` https://developer.android.com/reference/java/io/OutputStream#write(int)(int b) ` Writes the specified byte to this output stream. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/io/Closeable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/io/Closeable#close()() ` Closes this stream and releases any system resources associated with it. | ||
| From interface ` https://developer.android.com/reference/java/io/Flushable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/io/Flushable#flush()() ` Flushes this stream by writing any buffered output to the underlying stream. | ||
| From interface ` https://developer.android.com/reference/java/lang/Appendable ` |---|---| | ` abstract https://developer.android.com/reference/java/lang/Appendable` | ` https://developer.android.com/reference/java/lang/Appendable#append(char)(char c) ` Appends the specified character to this `Appendable`. | | ` abstract https://developer.android.com/reference/java/lang/Appendable` | ` https://developer.android.com/reference/java/lang/Appendable#append(java.lang.CharSequence,%20int,%20int)(https://developer.android.com/reference/java/lang/CharSequence csq, int start, int end) ` Appends a subsequence of the specified character sequence to this `Appendable`. | | ` abstract https://developer.android.com/reference/java/lang/Appendable` | ` https://developer.android.com/reference/java/lang/Appendable#append(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence csq) ` Appends the specified character sequence to this `Appendable`. | ||
| From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() ` Closes this resource, relinquishing any underlying resources. | ||

## Public constructors

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (File file)
```

Creates a new print stream, without automatic line flushing, with the
specified file. This convenience constructor creates the necessary
intermediate `https://developer.android.com/reference/java/io/OutputStreamWriter`,
which will encode characters using the [default charset](https://developer.android.com/reference/java/nio/charset/Charset#defaultCharset()) for this
instance of the Java virtual machine.

<br />

| Parameters ||
|---|---|
| `file` | `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. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/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 |
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager is present and `https://developer.android.com/reference/java/lang/SecurityManager#checkWrite(java.io.FileDescriptor)` denies write access to the file |

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (File file, 
                String csn)
```

Creates a new print stream, without automatic line flushing, with the
specified file and charset. This convenience constructor creates
the necessary intermediate `https://developer.android.com/reference/java/io/OutputStreamWriter`, which will encode characters using the provided
charset.

<br />

| Parameters ||
|---|---|
| `file` | `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. <br /> |
| `csn` | `String`: The name of a supported [charset](https://developer.android.com/reference/java/nio/charset/Charset) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/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 |
| `https://developer.android.com/reference/java/io/UnsupportedEncodingException` | If the named charset is not supported |
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager is present and `https://developer.android.com/reference/java/lang/SecurityManager#checkWrite(java.io.FileDescriptor)` denies write access to the file |

### PrintStream

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (File file, 
                Charset charset)
```

Creates a new print stream, without automatic line flushing, with the
specified file and charset. This convenience constructor creates
the necessary intermediate `https://developer.android.com/reference/java/io/OutputStreamWriter`, which will encode characters using the provided
charset.

<br />

| Parameters ||
|---|---|
| `file` | `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. <br /> |
| `charset` | `Charset`: A [charset](https://developer.android.com/reference/java/nio/charset/Charset) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs while opening or creating the file |
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager is present and `https://developer.android.com/reference/java/lang/SecurityManager#checkWrite(java.io.FileDescriptor)` denies write access to the file |

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (OutputStream out)
```

Creates a new print stream, without automatic line flushing, with the
specified OutputStream. Characters written to the stream are converted
to bytes using the platform's default character encoding.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: The output stream to which values and objects will be printed <br /> |

**See also:**

- `https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.OutputStream)`

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (OutputStream out, 
                boolean autoFlush)
```

Creates a new print stream, with the specified OutputStream and line
flushing. Characters written to the stream are converted to bytes using
the platform's default character encoding.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: The output stream to which values and objects will be printed <br /> |
| `autoFlush` | `boolean`: Whether 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 <br /> |

**See also:**

- `https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.OutputStream,%20boolean)`

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (OutputStream out, 
                boolean autoFlush, 
                String encoding)
```

Creates a new print stream, with the specified OutputStream, line
flushing, and character encoding.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: The output stream to which values and objects will be printed <br /> |
| `autoFlush` | `boolean`: Whether 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 <br /> |
| `encoding` | `String`: The name of a supported [character encoding](https://developer.android.com/reference/java/lang/package-summary.html#charenc) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/UnsupportedEncodingException` | If the named encoding is not supported |

### PrintStream

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (OutputStream out, 
                boolean autoFlush, 
                Charset charset)
```

Creates a new print stream, with the specified OutputStream, line
flushing and charset. This convenience constructor creates the necessary
intermediate `https://developer.android.com/reference/java/io/OutputStreamWriter`,
which will encode characters using the provided charset.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: The output stream to which values and objects will be printed <br /> |
| `autoFlush` | `boolean`: Whether 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 <br /> |
| `charset` | `Charset`: A [charset](https://developer.android.com/reference/java/nio/charset/Charset) <br /> |

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (String fileName)
```

Creates a new print stream, without automatic line flushing, with the
specified file name. This convenience constructor creates
the necessary intermediate `https://developer.android.com/reference/java/io/OutputStreamWriter`, which will encode characters using the
[default charset](https://developer.android.com/reference/java/nio/charset/Charset#defaultCharset())
for this instance of the Java virtual machine.

<br />

| Parameters ||
|---|---|
| `fileName` | `String`: 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. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/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 |
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager is present and `https://developer.android.com/reference/java/lang/SecurityManager#checkWrite(java.io.FileDescriptor)` denies write access to the file |

### PrintStream

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (String fileName, 
                String 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://developer.android.com/reference/java/io/OutputStreamWriter`, which will encode characters using the provided
charset.

<br />

| Parameters ||
|---|---|
| `fileName` | `String`: 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. <br /> |
| `csn` | `String`: The name of a supported [charset](https://developer.android.com/reference/java/nio/charset/Charset) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/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 |
| `https://developer.android.com/reference/java/io/UnsupportedEncodingException` | If the named charset is not supported |
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager is present and `https://developer.android.com/reference/java/lang/SecurityManager#checkWrite(java.io.FileDescriptor)` denies write access to the file |

### PrintStream

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream (String fileName, 
                Charset charset)
```

Creates a new print stream, without automatic line flushing, with the
specified file name and charset. This convenience constructor creates
the necessary intermediate `https://developer.android.com/reference/java/io/OutputStreamWriter`, which will encode characters using the provided
charset.

<br />

| Parameters ||
|---|---|
| `fileName` | `String`: 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. <br /> |
| `charset` | `Charset`: A [charset](https://developer.android.com/reference/java/nio/charset/Charset) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs while opening or creating the file |
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager is present and `https://developer.android.com/reference/java/lang/SecurityManager#checkWrite(java.io.FileDescriptor)` denies write access to the file |

## Public methods

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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)

<br />

<br />

| Parameters ||
|---|---|
| `c` | `char`: The 16-bit character to append <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream append (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())

<br />

<br />

| Parameters ||
|---|---|
| `csq` | `CharSequence`: 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"`. <br /> |
| `start` | `int`: The index of the first character in the subsequence <br /> |
| `end` | `int`: The index of the character following the last character in the subsequence <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | If `start` or `end` are negative, `start` is greater than `end`, or `end` is greater than `csq.length()` |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream append (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. For instance, invoking then `toString` method of a
character buffer will return a subsequence whose content depends upon
the buffer's position and limit.

<br />

| Parameters ||
|---|---|
| `csq` | `CharSequence`: The character sequence to append. If `csq` is `null`, then the four characters `"null"` are appended to this output stream. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

### checkError

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 />

<br />

| Returns ||
|---|---|
| `boolean` | `true` if and only if this stream has encountered an `IOException` other than `InterruptedIOException`, or the `setError` method has been invoked <br /> |

### close

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

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

<br />

**See also:**

- `https://developer.android.com/reference/java/io/OutputStream#close()`

### flush

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

**See also:**

- `https://developer.android.com/reference/java/io/OutputStream#flush()`

### format

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream format (String format, 
                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 `https://developer.android.com/reference/java/util/Locale#getDefault(java.util.Locale.Category)` with
`https://developer.android.com/reference/java/util/Locale.Category#FORMAT` category specified,
regardless of any previous invocations of other formatting methods on
this object.

<br />

| Parameters ||
|---|---|
| `format` | `String`: A format string as described in [Format string syntax](https://developer.android.com/reference/java/util/Formatter.html#syntax) <br /> |
| `args` | `Object`: 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://developer.android.com/reference/java/util/Formatter.html#syntax). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the `format` is `null` |
| `https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/Formatter.html#detail) section of the formatter class specification. |

### format

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream format (Locale l, 
                String format, 
                Object... args)
```

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

<br />

| Parameters ||
|---|---|
| `l` | `Locale`: The [locale](https://developer.android.com/reference/java/util/Locale) to apply during formatting. If `l` is `null` then no localization is applied. <br /> |
| `format` | `String`: A format string as described in [Format string syntax](https://developer.android.com/reference/java/util/Formatter.html#syntax) <br /> |
| `args` | `Object`: 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://developer.android.com/reference/java/util/Formatter.html#syntax). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the `format` is `null` |
| `https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/Formatter.html#detail) section of the formatter class specification. |

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (double d)
```

Prints a double-precision floating-point number. The string produced by
`https://developer.android.com/reference/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 `https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `d` | `double`: The `double` to be printed <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Double#toString(double)`

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (int i)
```

Prints an integer. The string produced by `https://developer.android.com/reference/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
`https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `i` | `int`: The `int` to be printed <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Integer#toString(int)`

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (boolean b)
```

Prints a boolean value. The string produced by `https://developer.android.com/reference/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
`https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `b` | `boolean`: The `boolean` to be printed <br /> |

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (char c)
```

Prints a character. The character is translated into one or more bytes
according to the character encoding given to the constructor, or the
platform's default character encoding if none specified. These bytes
are written in exactly the manner of the `https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `c` | `char`: The `char` to be printed <br /> |

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (long l)
```

Prints a long integer. The string produced by `https://developer.android.com/reference/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
`https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `l` | `long`: The `long` to be printed <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Long#toString(long)`

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (float f)
```

Prints a floating-point number. The string produced by `https://developer.android.com/reference/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
`https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `f` | `float`: The `float` to be printed <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Float#toString(float)`

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (String 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 character encoding given to the
constructor, or the platform's default character encoding if none
specified. These bytes are written in exactly the manner of the
`https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `s` | `String`: The `String` to be printed <br /> |

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (Object obj)
```

Prints an object. The string produced by the `https://developer.android.com/reference/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
`https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: The `Object` to be printed <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#toString()`

### print

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void print (char[] s)
```

Prints an array of characters. The characters are converted into bytes
according to the character encoding given to the constructor, or the
platform's default character encoding if none specified. These bytes
are written in exactly the manner of the `https://developer.android.com/reference/java/io/PrintStream#write(int)` method.

<br />

| Parameters ||
|---|---|
| `s` | `char`: The array of chars to be printed <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `s` is `null` |

### printf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream printf (Locale l, 
                String format, 
                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)

<br />

<br />

| Parameters ||
|---|---|
| `l` | `Locale`: The [locale](https://developer.android.com/reference/java/util/Locale) to apply during formatting. If `l` is `null` then no localization is applied. <br /> |
| `format` | `String`: A format string as described in [Format string syntax](https://developer.android.com/reference/java/util/Formatter.html#syntax) <br /> |
| `args` | `Object`: 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://developer.android.com/reference/java/util/Formatter.html#syntax). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the `format` is `null` |
| `https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/Formatter.html#detail) section of the formatter class specification. |

### printf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PrintStream printf (String format, 
                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)

<br />

<br />

| Parameters ||
|---|---|
| `format` | `String`: A format string as described in [Format string syntax](https://developer.android.com/reference/java/util/Formatter.html#syntax) <br /> |
| `args` | `Object`: 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://developer.android.com/reference/java/util/Formatter.html#syntax). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintStream` | This output stream <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If the `format` is `null` |
| `https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/Formatter.html#detail) section of the formatter class specification. |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (Object 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://developer.android.com/reference/java/io/PrintStream#print(java.lang.String)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `Object`: The `Object` to be printed. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (char x)
```

Prints a character and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(char)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `char`: The `char` to be printed. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (boolean x)
```

Prints a boolean and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(boolean)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `boolean`: The `boolean` to be printed <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (long x)
```

Prints a long and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(long)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `long`: a The `long` to be printed. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (int x)
```

Prints an integer and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(int)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `int`: The `int` to be printed. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (String x)
```

Prints a String and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(java.lang.String)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `String`: The `String` to be printed. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (char[] x)
```

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

<br />

| Parameters ||
|---|---|
| `x` | `char`: an array of chars to print. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (float x)
```

Prints a float and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(float)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `float`: The `float` to be printed. <br /> |

### println

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void println (double x)
```

Prints a double and then terminate the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintStream#print(double)` and then
`https://developer.android.com/reference/java/io/PrintStream#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `double`: The `double` to be printed. <br /> |

### write

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void write (byte[] buf)
```

Writes all bytes from the specified byte array to this stream. If
automatic flushing is enabled then the `flush` method will be
invoked on the underlying output stream.

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.

<br />

##### API Note:

- Although declared to throw `IOException`, this method never actually does so. Instead, like other methods that this class overrides, it sets an internal flag which may be tested via the `https://developer.android.com/reference/java/io/PrintStream#checkError()` method. To write an array of bytes without having to write a `catch` block for the `IOException`, use either `https://developer.android.com/reference/java/io/PrintStream#writeBytes(byte[])` or `https://developer.android.com/reference/java/io/PrintStream#write(byte[],%20int,%20int)`.

##### Implementation Requirements:

- This method is equivalent to `https://developer.android.com/reference/java/io/PrintStream#write(byte[],%20int,%20int)`.

| Parameters ||
|---|---|
| `buf` | `byte`: A byte array <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If an I/O error occurs. |

**See also:**

- `https://developer.android.com/reference/java/io/PrintStream#writeBytes(byte[])`
- `https://developer.android.com/reference/java/io/PrintStream#write(byte[],%20int,%20int)`

### write

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 on the underlying
output stream.

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.

<br />

| Parameters ||
|---|---|
| `buf` | `byte`: A byte array <br /> |
| `off` | `int`: Offset from which to start taking bytes <br /> |
| `len` | `int`: Number of bytes to write <br /> |

### write

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 on the underlying output stream.

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.

<br />

| Parameters ||
|---|---|
| `b` | `int`: The byte to be written <br /> |

**See also:**

- `https://developer.android.com/reference/java/io/PrintStream#print(char)`
- `https://developer.android.com/reference/java/io/PrintStream#println(char)`

### writeBytes

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeBytes (byte[] buf)
```

Writes all bytes from the specified byte array 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.

<br />

##### Implementation Requirements:

- This method is equivalent to `https://developer.android.com/reference/java/io/PrintStream#write(byte[],%20int,%20int)`.

| Parameters ||
|---|---|
| `buf` | `byte`: A byte array <br /> |

## Protected methods

### clearError

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void clearError ()
```

Clears the internal error state of this stream.

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

<br />

### setError

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void setError ()
```

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

This method will cause subsequent invocations of `https://developer.android.com/reference/java/io/PrintStream#checkError()` to return `true` until
`https://developer.android.com/reference/java/io/PrintStream#clearError()` is invoked.

<br />