- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Importance of StringReader class in Java?
The StringReader class is s subclass of a Reader class and it can be used to read the character stream in the form of a string which acts as a source to StringReader. The StringReader class overrides all the methods from a Reader class. The important methods of StringReader class are skip(), close(), mark(), markSupported(), reset() and etc.
Syntax
Public class StringReader extends Reader
Example
import java.io.StringReader; import java.io.IOException; public class StringReaderTest { public static void main(String[] args) { String str = "Welcome to Tutorials Point"; 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
Welcome to Tutorials Point
Advertisements