java.io

Class StringBufferInputStream

Implemented Interfaces:
Closeable

public class StringBufferInputStream
extends InputStream

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.

Since:
JDK1.0
See Also:
ByteArrayInputStream, StringReader

Field Summary

protected String
buffer
The string from which bytes are read.
protected int
count
The number of valid characters in the input stream buffer.
protected int
pos
The index of the next character to read from the input stream buffer.

Constructor Summary

StringBufferInputStream(String s)
Creates a string input stream to read data from the specified string.

Method Summary

int
available()
Returns the number of bytes that can be read from the input stream without blocking.
int
read()
Reads the next byte of data from this input stream.
int
read(b[] , int off, int len)
Reads up to len bytes of data from this input stream into an array of bytes.
void
reset()
Resets the input stream to begin reading from the first character of this input stream's underlying buffer.
long
skip(long n)
Skips n bytes of input from this input stream.

Methods inherited from class java.io.InputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buffer

protected String buffer
The string from which bytes are read.

count

protected int count
The number of valid characters in the input stream buffer.
See Also:
buffer

pos

protected int pos
The index of the next character to read from the input stream buffer.
See Also:
buffer

Constructor Details

StringBufferInputStream

public StringBufferInputStream(String s)
Creates a string input stream to read data from the specified string.
Parameters:
s - the underlying input buffer.
Usages and Demos :

View More Examples of StringBufferInputStream(String s)
   1:         BufferedInputStream b =
   2:       new BufferedInputStream(new StringBufferInputStream("ABCDEF"));
   3:         b.mark(3);
   4:         b.read();
   5:         b.read();

View Full Code Here
   1: 
   2:         InputStream inputStream = new StringBufferInputStream(content);
   3:         
   4:         try {
   5:             Document doc = factory.newDocumentBuilder().parse(inputStream);

View Full Code Here
   1:         clob_.string_ = clob_.string_.concat(str);
   2:         clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
   3:         clob_.unicodeStream_ 
   4:         ...
   5:             = new java.io.StringBufferInputStream(clob_.string_);
   6:         clob_.characterStream_ = new java.io.StringReader(clob_.string_);
   7:         clob_.setSqlLength(clob_.string_.length());
   8:         offset_ += b.length;

View Full Code Here
   1:         clob_.string_ = sb.toString();
   2:         clob_.asciiStream_ = new java.io.StringBufferInputStream(clob_.string_);
   3:         clob_.unicodeStream_ 
   4:         ...
   5:             = new java.io.StringBufferInputStream(clob_.string_);
   6:         clob_.characterStream_ = new java.io.StringReader(clob_.string_);
   7:         clob_.setSqlLength(clob_.string_.length());
   8:         offset_ = clob_.string_.length() + 1;

View Full Code Here
   1:     throws SoapException, RingException {
   2:         StringBufferInputStream sbis = new StringBufferInputStream(entry.getAttribute("content"));
   3:         try {
   4:             return AMXMLUtils.JAXB_Unmarshall(AmExportPipeline.class, sbis);
   5:         } catch (JAXBException e) {

View Full Code Here

Method Details

available

public int available()
Returns the number of bytes that can be read from the input stream without blocking.
Overrides:
available in interface InputStream
Returns:
the value of count - pos, which is the number of bytes remaining to be read from the input buffer.

read

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.

Overrides:
read in interface InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Usages and Demos :

View More Examples of read()
   1: 
   2:       StringBufferInputStream in2 =
   3:         ...
   4:           new StringBufferInputStream(s2);
   5:       int c;
   6:         ...
   7:       while((c = in2.read()) != -1)
   8:         System.out.print((char)c);
   9:         ...
  10:           new DataInputStream(
  11:             new StringBufferInputStream(s2));

View Full Code Here

read

public int read(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.

Overrides:
read in interface InputStream
Parameters:
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
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.

reset

public void reset()
Resets the input stream to begin reading from the first character of this input stream's underlying buffer.
Overrides:
reset in interface InputStream

skip

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.
Overrides:
skip in interface InputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.