English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
StringReader class is a subclass ofReader class, which can be used to read outcharacter streamacts as a source StringReader in the form of a string. TheStringReader The class will override all methods from the Reader class. Important methods of the StringReader classskip(), , close()
,,mark()
markSupported()
reset()
et al.
Public class StringReader extends Reader
import java.io.StringReader; import java.io.IOException; public class StringReaderTest { public static void main(String[] args) { String str = "Welcome to oldtoolbag.com"; StringReader strReader = new StringReader(str); try { int i; while((i = strReader.read()) != -1) { System.out.print((char)i); } } catch(IOException ioe) { System.out.println(ioe); } finally { if(strReader != null) { try { strReader.close(); } catch(Exception e) { System.out.println(e); } } } } }
Output Result
Welcome to oldtoolbag.com