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

# PrintWriter


`
public


class
PrintWriter
`


`


`

`

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


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.io.Writer](https://developer.android.com/reference/java/io/Writer) ||
|   | ↳ | java.io.PrintWriter |

<br />

*** ** * ** ***

Prints formatted representations of objects to a text-output stream. This
class implements all of the `print` methods found in `https://developer.android.com/reference/java/io/PrintStream`. It does not contain methods for writing raw bytes, for which
a program should use unencoded byte streams.

Unlike the `https://developer.android.com/reference/java/io/PrintStream` class, if automatic flushing is enabled
it will be done only when one of the `println`, `printf`, or
`format` methods is invoked, rather than whenever a newline character
happens to be output. These methods use the platform's own notion of line
separator rather than the newline character.

Methods in this class never throw I/O exceptions, although some of its
constructors may. The client may inquire as to whether any errors have
occurred by invoking `https://developer.android.com/reference/java/io/PrintWriter#checkError()`.

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

| ### Fields ||
|---|---|
| ` protected https://developer.android.com/reference/java/io/Writer` | `https://developer.android.com/reference/java/io/PrintWriter#out` The underlying character-output stream of this `PrintWriter`. |

| ### Inherited fields |
|---|
| From class `https://developer.android.com/reference/java/io/Writer` |---|---| | ` protected https://developer.android.com/reference/java/lang/Object` | `https://developer.android.com/reference/java/io/Writer#lock` The object used to synchronize operations on this stream. | |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.File)(https://developer.android.com/reference/java/io/File file) ` Creates a new PrintWriter, without automatic line flushing, with the specified file. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(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 PrintWriter, without automatic line flushing, with the specified file and charset. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(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 PrintWriter, without automatic line flushing, with the specified file and charset. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.OutputStream)(https://developer.android.com/reference/java/io/OutputStream out) ` Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.OutputStream,%20boolean)(https://developer.android.com/reference/java/io/OutputStream out, boolean autoFlush) ` Creates a new PrintWriter from an existing OutputStream. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(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 PrintWriter from an existing OutputStream. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.Writer)(https://developer.android.com/reference/java/io/Writer out) ` Creates a new PrintWriter, without automatic line flushing. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.io.Writer,%20boolean)(https://developer.android.com/reference/java/io/Writer out, boolean autoFlush) ` Creates a new PrintWriter. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(java.lang.String)(https://developer.android.com/reference/java/lang/String fileName) ` Creates a new PrintWriter, without automatic line flushing, with the specified file name. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(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 PrintWriter, without automatic line flushing, with the specified file name and charset. |
| ` https://developer.android.com/reference/java/io/PrintWriter#PrintWriter(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 PrintWriter, without automatic line flushing, with the specified file name and charset. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#append(char)(char c) ` Appends the specified character to this writer. |
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#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 writer. |
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#append(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence csq) ` Appends the specified character sequence to this writer. |
| ` boolean` | ` https://developer.android.com/reference/java/io/PrintWriter#checkError()() ` Flushes the stream if it's not closed and checks its error state. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#close()() ` Closes the stream and releases any system resources associated with it. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#flush()() ` Flushes the stream. |
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#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 writer using the specified format string and arguments. |
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#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 writer using the specified format string and arguments. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(double)(double d) ` Prints a double-precision floating-point number. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(int)(int i) ` Prints an integer. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(boolean)(boolean b) ` Prints a boolean value. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(char)(char c) ` Prints a character. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(long)(long l) ` Prints a long integer. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(float)(float f) ` Prints a floating-point number. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Prints a string. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Prints an object. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#print(char[])(char[] s) ` Prints an array of characters. |
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#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 writer using the specified format string and arguments. |
| ` https://developer.android.com/reference/java/io/PrintWriter` | ` https://developer.android.com/reference/java/io/PrintWriter#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 writer using the specified format string and arguments. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(java.lang.Object)(https://developer.android.com/reference/java/lang/Object x) ` Prints an Object and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(char)(char x) ` Prints a character and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(boolean)(boolean x) ` Prints a boolean value and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(long)(long x) ` Prints a long integer and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println()() ` Terminates the current line by writing the line separator string. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(int)(int x) ` Prints an integer and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(java.lang.String)(https://developer.android.com/reference/java/lang/String x) ` Prints a String and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(char[])(char[] x) ` Prints an array of characters and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(float)(float x) ` Prints a floating-point number and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#println(double)(double x) ` Prints a double-precision floating-point number and then terminates the line. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#write(int)(int c) ` Writes a single character. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#write(char[],%20int,%20int)(char[] buf, int off, int len) ` Writes A Portion of an array of characters. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#write(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Writes a string. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#write(java.lang.String,%20int,%20int)(https://developer.android.com/reference/java/lang/String s, int off, int len) ` Writes a portion of a string. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#write(char[])(char[] buf) ` Writes an array of characters. |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#clearError()() ` Clears the error state of this stream. |
| ` void` | ` https://developer.android.com/reference/java/io/PrintWriter#setError()() ` Indicates that an error has occurred. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/io/Writer ` |---|---| | ` https://developer.android.com/reference/java/io/Writer` | ` https://developer.android.com/reference/java/io/Writer#append(char)(char c) ` Appends the specified character to this writer. | | ` https://developer.android.com/reference/java/io/Writer` | ` https://developer.android.com/reference/java/io/Writer#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 writer. | | ` https://developer.android.com/reference/java/io/Writer` | ` https://developer.android.com/reference/java/io/Writer#append(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence csq) ` Appends the specified character sequence to this writer. | | ` abstract void` | ` https://developer.android.com/reference/java/io/Writer#close()() ` Closes the stream, flushing it first. | | ` abstract void` | ` https://developer.android.com/reference/java/io/Writer#flush()() ` Flushes the stream. | | ` static https://developer.android.com/reference/java/io/Writer` | ` https://developer.android.com/reference/java/io/Writer#nullWriter()() ` Returns a new `Writer` which discards all characters. | | ` void` | ` https://developer.android.com/reference/java/io/Writer#write(java.lang.String)(https://developer.android.com/reference/java/lang/String str) ` Writes a string. | | ` void` | ` https://developer.android.com/reference/java/io/Writer#write(int)(int c) ` Writes a single character. | | ` void` | ` https://developer.android.com/reference/java/io/Writer#write(java.lang.String,%20int,%20int)(https://developer.android.com/reference/java/lang/String str, int off, int len) ` Writes a portion of a string. | | ` abstract void` | ` https://developer.android.com/reference/java/io/Writer#write(char[],%20int,%20int)(char[] cbuf, int off, int len) ` Writes a portion of an array of characters. | | ` void` | ` https://developer.android.com/reference/java/io/Writer#write(char[])(char[] cbuf) ` Writes an array of characters. | ||
| 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/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/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/AutoCloseable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() ` Closes this resource, relinquishing any underlying resources. | ||

## Fields

### out

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

```
protected Writer out
```

The underlying character-output stream of this
`PrintWriter`.

<br />

## Public constructors

### PrintWriter

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

```
public PrintWriter (File file)
```

Creates a new PrintWriter, 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 writer. 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 |

### PrintWriter

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

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

Creates a new PrintWriter, 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 writer. 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 |

### PrintWriter

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

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

Creates a new PrintWriter, 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 writer. 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 |

### PrintWriter

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

```
public PrintWriter (OutputStream out)
```

Creates a new PrintWriter, without automatic line flushing, from an
existing OutputStream. This convenience constructor creates the
necessary intermediate OutputStreamWriter, which will convert characters
into bytes using the default character encoding.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: An output stream <br /> |

**See also:**

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

### PrintWriter

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

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

Creates a new PrintWriter from an existing OutputStream. This
convenience constructor creates the necessary intermediate
OutputStreamWriter, which will convert characters into bytes using the
default character encoding.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: An output stream <br /> |
| `autoFlush` | `boolean`: A boolean; if true, the `println`, `printf`, or `format` methods will flush the output buffer <br /> |

**See also:**

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

### PrintWriter

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

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

Creates a new PrintWriter from an existing OutputStream. This
convenience constructor creates the necessary intermediate
OutputStreamWriter, which will convert characters into bytes using the
specified charset.

<br />

| Parameters ||
|---|---|
| `out` | `OutputStream`: An output stream <br /> |
| `autoFlush` | `boolean`: A boolean; if true, the `println`, `printf`, or `format` methods will flush the output buffer <br /> |
| `charset` | `Charset`: A [charset](https://developer.android.com/reference/java/nio/charset/Charset) <br /> |

### PrintWriter

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

```
public PrintWriter (Writer out)
```

Creates a new PrintWriter, without automatic line flushing.

<br />

| Parameters ||
|---|---|
| `out` | `Writer`: A character-output stream <br /> |

### PrintWriter

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

```
public PrintWriter (Writer out, 
                boolean autoFlush)
```

Creates a new PrintWriter.

<br />

| Parameters ||
|---|---|
| `out` | `Writer`: A character-output stream <br /> |
| `autoFlush` | `boolean`: A boolean; if true, the println, printf, or format methods will flush the output buffer <br /> |

### PrintWriter

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

```
public PrintWriter (String fileName)
```

Creates a new PrintWriter, 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 writer. 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 string 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 |

### PrintWriter

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

```
public PrintWriter (String fileName, 
                String csn)
```

Creates a new PrintWriter, 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 writer. 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 string 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 |

### PrintWriter

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

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

Creates a new PrintWriter, 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 writer. 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 PrintWriter append (char c)
```

Appends the specified character to this writer.

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

    out.write(c)

<br />

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintWriter` | This writer <br /> |

### append

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

```
public PrintWriter append (CharSequence csq, 
                int start, 
                int end)
```

Appends a subsequence of the specified character sequence to this writer.

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.write(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/PrintWriter` | This writer <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 PrintWriter append (CharSequence csq)
```

Appends the specified character sequence to this writer.

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

    out.write(csq.toString())

Depending on the specification of `toString` for the
character sequence `csq`, the entire sequence may not be
appended. For instance, invoking the `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 writer. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/PrintWriter` | This writer <br /> |

### checkError

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

```
public boolean checkError ()
```

Flushes the stream if it's not closed and checks its error state.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the print stream has encountered an error, either on the underlying output stream or during a format conversion. <br /> |

### close

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

```
public void close ()
```

Closes the stream and releases any system resources associated
with it. Closing a previously closed stream has no effect.

<br />

**See also:**

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

### flush

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

```
public void flush ()
```

Flushes the stream.

<br />

**See also:**

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

### format

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

```
public PrintWriter format (String format, 
                Object... args)
```

Writes a formatted string to this writer using the specified format
string and arguments. If automatic flushing is enabled, calls to this
method will flush the output buffer.

The locale always used is the one returned by `https://developer.android.com/reference/java/util/Locale#getDefault()`, 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/PrintWriter` | This writer <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 PrintWriter format (Locale l, 
                String format, 
                Object... args)
```

Writes a formatted string to this writer using the specified format
string and arguments. If automatic flushing is enabled, calls to this
method will flush the output buffer.

<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/PrintWriter` | This writer <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/PrintWriter#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/PrintWriter#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/PrintWriter#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 platform's default character encoding, and these bytes
are written in exactly the manner of the `https://developer.android.com/reference/java/io/PrintWriter#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/PrintWriter#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/PrintWriter#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 platform's default character
encoding, and these bytes are written in exactly the manner of the
`https://developer.android.com/reference/java/io/PrintWriter#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/PrintWriter#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 platform's default character encoding, and these bytes
are written in exactly the manner of the `https://developer.android.com/reference/java/io/PrintWriter#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 PrintWriter printf (Locale l, 
                String format, 
                Object... args)
```

A convenience method to write a formatted string to this writer using
the specified format string and arguments. If automatic flushing is
enabled, calls to this method will flush the output buffer.

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/PrintWriter` | This writer <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 PrintWriter printf (String format, 
                Object... args)
```

A convenience method to write a formatted string to this writer using
the specified format string and arguments. If automatic flushing is
enabled, calls to this method will flush the output buffer.

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/PrintWriter` | This writer <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 terminates 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/PrintWriter#print(java.lang.String)` and then
`https://developer.android.com/reference/java/io/PrintWriter#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 terminates the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(char)` and then `https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `char`: the `char` value 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 value and then terminates the line. This method behaves
as though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(boolean)` and then
`https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `boolean`: the `boolean` value 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 integer and then terminates the line. This method behaves
as though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(long)` and then
`https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `long`: the `long` value 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 terminates the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(int)` and then `https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `int`: the `int` value 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 terminates the line. This method behaves as
though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(java.lang.String)` and then
`https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `String`: the `String` value 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 terminates the line. This method
behaves as though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(char[])` and then
`https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `char`: the array of `char` values to be printed <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 floating-point number and then terminates the line. This method
behaves as though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(float)` and then
`https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `float`: the `float` value 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-precision floating-point number and then terminates the
line. This method behaves as though it invokes `https://developer.android.com/reference/java/io/PrintWriter#print(double)` and then `https://developer.android.com/reference/java/io/PrintWriter#println()`.

<br />

| Parameters ||
|---|---|
| `x` | `double`: the `double` value to be printed <br /> |

### write

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

```
public void write (int c)
```

Writes a single character.

<br />

| Parameters ||
|---|---|
| `c` | `int`: int specifying a character to be written. <br /> |

### write

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

```
public void write (char[] buf, 
                int off, 
                int len)
```

Writes A Portion of an array of characters.

<br />

| Parameters ||
|---|---|
| `buf` | `char`: Array of characters <br /> |
| `off` | `int`: Offset from which to start writing characters <br /> |
| `len` | `int`: Number of characters to write <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | If the values of the `off` and `len` parameters cause the corresponding method of the underlying `Writer` to throw an `IndexOutOfBoundsException` |

### write

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

```
public void write (String s)
```

Writes a string. This method cannot be inherited from the Writer class
because it must suppress I/O exceptions.

<br />

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

### write

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

```
public void write (String s, 
                int off, 
                int len)
```

Writes a portion of a string.

<br />

| Parameters ||
|---|---|
| `s` | `String`: A String <br /> |
| `off` | `int`: Offset from which to start writing characters <br /> |
| `len` | `int`: Number of characters to write <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | If the values of the `off` and `len` parameters cause the corresponding method of the underlying `Writer` to throw an `IndexOutOfBoundsException` |

### write

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

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

Writes an array of characters. This method cannot be inherited from the
Writer class because it must suppress I/O exceptions.

<br />

| Parameters ||
|---|---|
| `buf` | `char`: Array of characters to be written <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 error state of this stream.

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

<br />

### setError

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

```
protected void setError ()
```

Indicates that an error has occurred.

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

<br />