Java IO Tutorial - Java StringReader(String s) Constructor








Syntax

StringReader(String s) constructor from StringReader has the following syntax.

public StringReader(String s)

Example

In the following code shows how to use StringReader.StringReader(String s) constructor.

/*from ww  w .j  a  va 2 s. com*/

import java.io.IOException;
import java.io.StringReader;

public class Main {
  public static void main(String[] argv) throws IOException{
    StringReader stringReader = new StringReader("java2s.com");
    System.out.println(stringReader.read());
    
    stringReader.close();
  }
}

The code above generates the following result.