Android
java.io
public class

java.io.StringBufferInputStream

java.lang.Object
java.io.InputStream Closeable
java.io.StringBufferInputStream

This class is deprecated. Use StringReader

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.
Methods inherited from class java.io.InputStream
Methods inherited from class java.lang.Object
Methods inherited from interface java.io.Closeable

Details

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.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48