Home > Java > javaTutorial > What is the importance of StringReader class in Java?

What is the importance of StringReader class in Java?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-11 08:49:02
forward
714 people have browsed it

The

What is the importance of StringReader class in Java?

StringReader class is a subclass of the Reader class, which can be used to read characters from the stream Use string form as the source of StringReader. The StringReader class will override all methods in the Reader class. The important methods of the StringReader class include skip(), close(), mark(), markSupported(), reset(), etc.

Syntax

<strong>Public class StringReader extends Reader</strong>
Copy after login

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);
            }
         }
      }
   }
}
Copy after login

Output

Welcome to Tutorials Point
Copy after login

The above is the detailed content of What is the importance of StringReader class in Java?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template