StringReader
In this chapter you will learn:
Use StringReader
StringReader is a character stream whose source is a string.
import java.io.StringReader;
//from j av a 2s . c o m
public class Main {
public static void main(String[] args) throws Exception{
StringReader reader = new StringReader("java2s.com");
int ch = 0;
while(true){
ch = reader.read();
if(ch == -1){
break;
}
System.out.println((char)ch);
}
}
}
The output:
j// j a v a2 s .c o m
a
v
a
2
s
.
c
o
m
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » I/O