All About Class StringBufferInputStream in Java

0
60
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

StringBufferInputStream in Java
Class StringBufferInputStream in Java
StringBufferInputStream in Java

StringBufferInputStream in Java:

StringBufferInputStream class allows an application to create an input stream where bytes read are supplied by the contents of a String.Application can also read bytes from a byte array by using a ByteArrayInputStream. So this stream converts a String into a Input Stream. The String however uses a StringBuffer to implement StringBufferInoutStream.Only the low eight bits of each character in the string are used by this class.We need to connect StringBufferInputStream to a FilterInputStream object to provide a useful interface.

The structure of the class StringBufferInputStream is given as:


public class java.io.StringBufferInputStream extends java.io.InputStream{
protected String buffer;//The string from which bytes are read.
protected int count;//the number of valid characters in the input stream buffer
protect int pos;//the index of the next characters to read data from specified input stream buffer.
//constructor
public StringBufferInputStream(String s);
//creates a StringBufferInputStream object to read data from specified String.
//methods:
public int available();
public int read();
public int read(byte b[],int offSet,int length);
public void reset();
public long skip(long n);
}
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here