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

# StringBufferInputStream


`
public


class
StringBufferInputStream
`


`


`

`

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


`

`


`

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

<br />

*** ** * ** ***


**This class was deprecated
in API level 1.**   

This class does not properly convert characters into bytes. As
of JDK 1.1, the preferred way to create a stream from a
string is via the `StringReader` class.

This class allows an application to create an input stream in
which the bytes read are supplied by the contents of a string.
Applications can also read bytes from a byte array by using a
`ByteArrayInputStream`.


Only the low eight bits of each character in the string are used by
this class.
**See also:**

- `https://developer.android.com/reference/java/io/ByteArrayInputStream`
- `https://developer.android.com/reference/java/io/StringReader`

## Summary

| ### Fields ||
|---|---|
| ` protected https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/java/io/StringBufferInputStream#buffer` The string from which bytes are read. |
| ` protected int` | `https://developer.android.com/reference/java/io/StringBufferInputStream#count` The number of valid characters in the input stream buffer. |
| ` protected int` | `https://developer.android.com/reference/java/io/StringBufferInputStream#pos` The index of the next character to read from the input stream buffer. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/io/StringBufferInputStream#StringBufferInputStream(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Creates a string input stream to read data from the specified string. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/java/io/StringBufferInputStream#available()() ` Returns the number of bytes that can be read from the input stream without blocking. |
| ` int` | ` https://developer.android.com/reference/java/io/StringBufferInputStream#read()() ` Reads the next byte of data from this input stream. |
| ` int` | ` https://developer.android.com/reference/java/io/StringBufferInputStream#read(byte[],%20int,%20int)(byte[] b, int off, int len) ` Reads up to `len` bytes of data from this input stream into an array of bytes. |
| ` void` | ` https://developer.android.com/reference/java/io/StringBufferInputStream#reset()() ` Resets the input stream to begin reading from the first character of this input stream's underlying buffer. |
| ` long` | ` https://developer.android.com/reference/java/io/StringBufferInputStream#skip(long)(long n) ` Skips `n` bytes of input from this input stream. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/io/InputStream ` |---|---| | ` int` | ` https://developer.android.com/reference/java/io/InputStream#available()() ` Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. | | ` void` | ` https://developer.android.com/reference/java/io/InputStream#close()() ` Closes this input stream and releases any system resources associated with the stream. | | ` void` | ` https://developer.android.com/reference/java/io/InputStream#mark(int)(int readlimit) ` Marks the current position in this input stream. | | ` boolean` | ` https://developer.android.com/reference/java/io/InputStream#markSupported()() ` Tests if this input stream supports the `mark` and `reset` methods. | | ` static https://developer.android.com/reference/java/io/InputStream` | ` https://developer.android.com/reference/java/io/InputStream#nullInputStream()() ` Returns a new `InputStream` that reads no bytes. | | ` int` | ` https://developer.android.com/reference/java/io/InputStream#read(byte[])(byte[] b) ` Reads some number of bytes from the input stream and stores them into the buffer array `b`. | | ` abstract int` | ` https://developer.android.com/reference/java/io/InputStream#read()() ` Reads the next byte of data from the input stream. | | ` int` | ` https://developer.android.com/reference/java/io/InputStream#read(byte[],%20int,%20int)(byte[] b, int off, int len) ` Reads up to `len` bytes of data from the input stream into an array of bytes. | | ` byte[]` | ` https://developer.android.com/reference/java/io/InputStream#readAllBytes()() ` Reads all remaining bytes from the input stream. | | ` int` | ` https://developer.android.com/reference/java/io/InputStream#readNBytes(byte[],%20int,%20int)(byte[] b, int off, int len) ` Reads the requested number of bytes from the input stream into the given byte array. | | ` byte[]` | ` https://developer.android.com/reference/java/io/InputStream#readNBytes(int)(int len) ` Reads up to a specified number of bytes from the input stream. | | ` void` | ` https://developer.android.com/reference/java/io/InputStream#reset()() ` Repositions this stream to the position at the time the `mark` method was last called on this input stream. | | ` long` | ` https://developer.android.com/reference/java/io/InputStream#skip(long)(long n) ` Skips over and discards `n` bytes of data from this input stream. | | ` void` | ` https://developer.android.com/reference/java/io/InputStream#skipNBytes(long)(long n) ` Skips over and discards exactly `n` bytes of data from this input stream. | | ` long` | ` https://developer.android.com/reference/java/io/InputStream#transferTo(java.io.OutputStream)(https://developer.android.com/reference/java/io/OutputStream out) ` Reads all bytes from this input stream and writes the bytes to the given output stream 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/AutoCloseable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() ` Closes this resource, relinquishing any underlying resources. | ||

## Fields

### buffer

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

```
protected String buffer
```

The string from which bytes are read.

<br />

### count

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

```
protected int count
```

The number of valid characters in the input stream buffer.

<br />

**See also:**

- `https://developer.android.com/reference/java/io/StringBufferInputStream#buffer`

### pos

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

```
protected int pos
```

The index of the next character to read from the input stream buffer.

<br />

**See also:**

- `https://developer.android.com/reference/java/io/StringBufferInputStream#buffer`

## Public constructors

### StringBufferInputStream

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

```
public StringBufferInputStream (String s)
```

Creates a string input stream to read data from the specified string.

<br />

| Parameters ||
|---|---|
| `s` | `String`: the underlying input buffer. <br /> |

## Public methods

### available

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

```
public int available ()
```

Returns the number of bytes that can be read from the input
stream without blocking.

<br />

| Returns ||
|---|---|
| `int` | the value of `count - pos`, which is the number of bytes remaining to be read from the input buffer. <br /> |

### read

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

```
public int read ()
```

Reads the next byte of data from this input stream. The value
byte is returned as an `int` in the range
`0` to `255`. If no byte is available
because the end of the stream has been reached, the value
`-1` is returned.


The `read` method of
`StringBufferInputStream` cannot block. It returns the
low eight bits of the next character in this input stream's buffer.

<br />

| Returns ||
|---|---|
| `int` | the next byte of data, or `-1` if the end of the stream is reached. <br /> |

### read

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

```
public int read (byte[] b, 
                int off, 
                int len)
```

Reads up to `len` bytes of data from this input stream
into an array of bytes.


The `read` method of
`StringBufferInputStream` cannot block. It copies the
low eight bits from the characters in this input stream's buffer into
the byte array argument.

<br />

| Parameters ||
|---|---|
| `b` | `byte`: the buffer into which the data is read. <br /> |
| `off` | `int`: the start offset of the data. <br /> |
| `len` | `int`: the maximum number of bytes read. <br /> |

| Returns ||
|---|---|
| `int` | the total number of bytes read into the buffer, or `-1` if there is no more data because the end of the stream has been reached. <br /> |

### reset

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

```
public void reset ()
```

Resets the input stream to begin reading from the first character
of this input stream's underlying buffer.

<br />

### skip

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

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

Skips `n` bytes of input from this input stream. Fewer
bytes might be skipped if the end of the input stream is reached.

<br />

| Parameters ||
|---|---|
| `n` | `long`: the number of bytes to be skipped. <br /> |

| Returns ||
|---|---|
| `long` | the actual number of bytes skipped. <br /> |