加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090321134753/http://developer.android.com:80/reference/java/io/StringBufferInputStream.html
public class

StringBufferInputStream

extends InputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.StringBufferInputStream

This class is deprecated.Use StringReader

Class Overview

StringBufferInputStream is a class for to allow a String to be used as an InputStream.

Summary

Fields
protected String buffer The String containing the data to read.
protected int count The total number of characters inside the buffer.
protected int pos The current position within the String buffer.
Public Constructors
StringBufferInputStream(String str)
Constructs a new StringBufferInputStream on the String str.
Public Methods
synchronized int available()
Returns an int representing then number of characters that are available to read.
synchronized int read(byte[] b, int offset, int length)
Reads at most length bytes from this InputStream and stores them in byte array b starting at offset.
synchronized int read()
Reads a single byte from this InputStream and returns the result as an int.
synchronized void reset()
Reset this InputStream to position 0.
synchronized long skip(long n)
Skips count number of characters in this InputStream.
[Expand]
Inherited Methods
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable

Fields

protected String buffer

The String containing the data to read.

protected int count

The total number of characters inside the buffer.

protected int pos

The current position within the String buffer.

Public Constructors

public StringBufferInputStream (String str)

Constructs a new StringBufferInputStream on the String str.

Parameters
str the String to read characters from.

Public Methods

public synchronized int available ()

Returns an int representing then number of characters that are available to read.

Returns
  • the number of characters available.

public synchronized int read (byte[] b, int offset, int length)

Reads at most length bytes from this InputStream and stores them in byte array b starting at offset. Answer the number of bytes actually read or -1 if no bytes were read and end of stream was encountered.

Parameters
b the byte array in which to store the read bytes.
offset the offset in b to store the read bytes.
length the maximum number of bytes to store in b.
Returns
  • the number of bytes actually read or -1 if end of stream.

public synchronized int read ()

Reads a single byte from this InputStream and returns the result as an int. The low-order byte is returned or -1 of the end of stream was encountered.

Returns
  • the byte read or -1 if end of stream.

public synchronized void reset ()

Reset this InputStream to position 0. Reads/Skips will now take place from this position.

public synchronized long skip (long n)

Skips count number of characters in this InputStream. Subsequent read()'s will not return these characters unless reset() is used.

Parameters
n the number of characters to skip.
Returns
  • the number of characters actually skipped.