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.

Class declaration

public class StringReader extends Reader

Methods of PrintWriter class

  1. int read()

    It is used to read a single character.

  2. int read(char[] cbuf, int off, int len)

    It is used to mark the present position in a stream.

  3. boolean ready()

    It is used to tell whether the stream is ready to be read.

  4. boolean markSupported()

    It is used to tell whether the stream supports mark() operation.

  5. void unread(byte[] b)

    It is used to pushes back the character by copying it to the pushback buffer.

  6. void reset()

    It is used to reset the stream.

Example :

Flash Soon



© Sapster 2017