Javatpoint Logo
Javatpoint Logo

Java StringReader Class

Java StringReader class is a character stream with string as a source. It takes an input string and changes it into character stream. It inherits Reader class.

In StringReader class, system resources like network sockets and files are not used, therefore closing the StringReader is not necessary.


Java StringReader class declaration

Let's see the declaration for Java.io.StringReader class:


Methods of StringReader class

Method Description
int read() It is used to read a single character.
int read(char[] cbuf, int off, int len) It is used to read a character into a portion of an array.
boolean ready() It is used to tell whether the stream is ready to be read.
boolean markSupported() It is used to tell whether the stream support mark() operation.
long skip(long ns) It is used to skip the specified number of character in a stream
void mark(int readAheadLimit) It is used to mark the mark the present position in a stream.
void reset() It is used to reset the stream.
void close() It is used to close the stream.

Java StringReader Example

Output:

Hello Java!! 
Welcome to Javatpoint.




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA