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/CharArrayReader#lfields) \| [Inherited Fields](https://developer.android.com/reference/java/io/CharArrayReader#inhfields) \| [Ctors](https://developer.android.com/reference/java/io/CharArrayReader#pubctors) \| [Methods](https://developer.android.com/reference/java/io/CharArrayReader#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/io/CharArrayReader#inhmethods)

# CharArrayReader

` public class CharArrayReader `   
` ` ` extends https://developer.android.com/reference/java/io/Reader ` ` `

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

<br />

*** ** * ** ***

This class implements a character buffer that can be used as a character-input stream.

## Summary

| ### Fields ||
|---|---|
| ` protected char[]` | `https://developer.android.com/reference/java/io/CharArrayReader#buf` The character buffer. |
| ` protected int` | `https://developer.android.com/reference/java/io/CharArrayReader#count` The index of the end of this buffer. |
| ` protected int` | `https://developer.android.com/reference/java/io/CharArrayReader#markedPos` The position of mark in buffer. |
| ` protected int` | `https://developer.android.com/reference/java/io/CharArrayReader#pos` The current buffer position. |

### Inherited fields

From class `https://developer.android.com/reference/java/io/Reader` ` protected https://developer.android.com/reference/java/lang/Object` `https://developer.android.com/reference/java/io/Reader#lock`

The object used to synchronize operations on this stream.

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/io/CharArrayReader#CharArrayReader(char[])(char[] buf) ` Creates a CharArrayReader from the specified array of chars. |
| ` https://developer.android.com/reference/java/io/CharArrayReader#CharArrayReader(char[],%20int,%20int)(char[] buf, int offset, int length) ` Creates a CharArrayReader from the specified array of chars. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/java/io/CharArrayReader#close()() ` Closes the stream and releases any system resources associated with it. |
| ` void` | ` https://developer.android.com/reference/java/io/CharArrayReader#mark(int)(int readAheadLimit) ` Marks the present position in the stream. |
| ` boolean` | ` https://developer.android.com/reference/java/io/CharArrayReader#markSupported()() ` Tells whether this stream supports the mark() operation, which it does. |
| ` int` | ` https://developer.android.com/reference/java/io/CharArrayReader#read()() ` Reads a single character. |
| ` int` | ` https://developer.android.com/reference/java/io/CharArrayReader#read(char[],%20int,%20int)(char[] cbuf, int off, int len) ` Reads characters into a portion of an array. |
| ` int` | ` https://developer.android.com/reference/java/io/CharArrayReader#read(java.nio.CharBuffer)(https://developer.android.com/reference/java/nio/CharBuffer target) ` Attempts to read characters into the specified character buffer. |
| ` boolean` | ` https://developer.android.com/reference/java/io/CharArrayReader#ready()() ` Tells whether this stream is ready to be read. |
| ` void` | ` https://developer.android.com/reference/java/io/CharArrayReader#reset()() ` Resets the stream to the most recent mark, or to the beginning if it has never been marked. |
| ` long` | ` https://developer.android.com/reference/java/io/CharArrayReader#skip(long)(long n) ` Skips characters. |

### Inherited methods

From class ` https://developer.android.com/reference/java/io/Reader ` ` abstract void` ` https://developer.android.com/reference/java/io/Reader#close()() `

Closes the stream and releases any system resources associated with it.
` void` ` https://developer.android.com/reference/java/io/Reader#mark(int)(int readAheadLimit) `

Marks the present position in the stream.
` boolean` ` https://developer.android.com/reference/java/io/Reader#markSupported()() `

Tells whether this stream supports the mark() operation.
` static https://developer.android.com/reference/java/io/Reader` ` https://developer.android.com/reference/java/io/Reader#nullReader()() `

Returns a new `Reader` that reads no characters.
` int` ` https://developer.android.com/reference/java/io/Reader#read()() `

Reads a single character.
` abstract int` ` https://developer.android.com/reference/java/io/Reader#read(char[],%20int,%20int)(char[] cbuf, int off, int len) `

Reads characters into a portion of an array.
` int` ` https://developer.android.com/reference/java/io/Reader#read(char[])(char[] cbuf) `

Reads characters into an array.
` int` ` https://developer.android.com/reference/java/io/Reader#read(java.nio.CharBuffer)(https://developer.android.com/reference/java/nio/CharBuffer target) `

Attempts to read characters into the specified character buffer.
` boolean` ` https://developer.android.com/reference/java/io/Reader#ready()() `

Tells whether this stream is ready to be read.
` void` ` https://developer.android.com/reference/java/io/Reader#reset()() `

Resets the stream.
` long` ` https://developer.android.com/reference/java/io/Reader#skip(long)(long n) `

Skips characters.
` long` ` https://developer.android.com/reference/java/io/Reader#transferTo(java.io.Writer)(https://developer.android.com/reference/java/io/Writer out) `

Reads all characters from this reader and writes the characters to the given writer in the order that they are read.
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/lang/Readable ` ` abstract int` ` https://developer.android.com/reference/java/lang/Readable#read(java.nio.CharBuffer)(https://developer.android.com/reference/java/nio/CharBuffer cb) `

Attempts to read characters into the specified character buffer.
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

### buf

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

```
protected char[] buf
```

The character buffer.

<br />

### count

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

```
protected int count
```

The index of the end of this buffer. There is not valid data at or beyond this index.

<br />

### markedPos

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

```
protected int markedPos
```

The position of mark in buffer.

<br />

### pos

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

```
protected int pos
```

The current buffer position.

<br />

## Public constructors

### CharArrayReader

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

```
public CharArrayReader (char[] buf)
```

Creates a CharArrayReader from the specified array of chars.

<br />

| Parameters ||
|---|---|
| `buf` | `char`: Input buffer (not copied) <br /> |

### CharArrayReader

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

```
public CharArrayReader (char[] buf, 
                int offset, 
                int length)
```

Creates a CharArrayReader from the specified array of chars.

The resulting reader will start reading at the given `offset`. The total number of `char` values that can be read from this reader will be either `length` or `buf.length-offset`, whichever is smaller.

<br />

| Parameters ||
|---|---|
| `buf` | `char`: Input buffer (not copied) <br /> |
| `offset` | `int`: Offset of the first char to read <br /> |
| `length` | `int`: Number of chars to read <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `offset` is negative or greater than `buf.length`, or if `length` is negative, or if the sum of these two values is negative. |

## Public methods

### 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. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect. This method will block while there is another thread blocking on the reader.

<br />

### mark

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

```
public void mark (int readAheadLimit)
```

Marks the present position in the stream. Subsequent calls to reset() will reposition the stream to this point.

<br />

| Parameters ||
|---|---|
| `readAheadLimit` | `int`: Limit on the number of characters that may be read while still preserving the mark. Because the stream's input comes from a character array, there is no actual limit; hence this argument is ignored. <br /> |

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

### markSupported

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

```
public boolean markSupported ()
```

Tells whether this stream supports the mark() operation, which it does.

<br />

| Returns ||
|---|---|
| `boolean` | true if and only if this stream supports the mark operation. <br /> |

### read

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

```
public int read ()
```

Reads a single character.

<br />

| Returns ||
|---|---|
| `int` | The character read, as an integer in the range 0 to 65535 (`0x00-0xffff`), or -1 if the end of the stream has been reached <br /> |

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

### read

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

```
public int read (char[] cbuf, 
                int off, 
                int len)
```

Reads characters into a portion of an array.

If `len` is zero, then no characters are read and `0` is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value `-1` is returned; otherwise, at least one character is read and stored into `cbuf`.

<br />

| Parameters ||
|---|---|
| `cbuf` | `char`: <br /> |
| `off` | `int`: <br /> |
| `len` | `int`: <br /> |

| Returns ||
|---|---|
| `int` | The number of characters read, or -1 if the end of the stream has been reached <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` |   |

### read

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

```
public int read (CharBuffer target)
```

Attempts to read characters into the specified character buffer. The buffer is used as a repository of characters as-is: the only changes made are the results of a put operation. No flipping or rewinding of the buffer is performed.

<br />

| Parameters ||
|---|---|
| `target` | `CharBuffer`: the buffer to read characters into <br /> |

| Returns ||
|---|---|
| `int` | The number of characters added to the buffer, or -1 if this source of characters is at its end <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### ready

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

```
public boolean ready ()
```

Tells whether this stream is ready to be read. Character-array readers are always ready to be read.

<br />

| Returns ||
|---|---|
| `boolean` | True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block. <br /> |

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

### reset

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

```
public void reset ()
```

Resets the stream to the most recent mark, or to the beginning if it has never been marked.

<br />

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

### skip

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

```
public long skip (long n)
```

Skips characters. If the stream is already at its end before this method is invoked, then no characters are skipped and zero is returned.

The `n` parameter may be negative, even though the `skip` method of the `https://developer.android.com/reference/java/io/Reader` superclass throws an exception in this case. If `n` is negative, then this method does nothing and returns `0`.

<br />

| Parameters ||
|---|---|
| `n` | `long`: <br /> |

| Returns ||
|---|---|
| `long` | The number of characters actually skipped <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |