StringReader class는 Reader 의 하위 클래스입니다. 클래스이며 문자 를 읽는 데 사용할 수 있습니다. 스트림 StringReader에 대한 소스 역할을 하는 문자열 형식입니다. StringReader 클래스는 Reader 클래스의 모든 메서드를 재정의합니다. StringReader 클래스의 중요한 메소드는 skip(), close(), mark(), markSupported(), reset() 등
구문
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 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);
}
}
}
}
} 출력
Welcome to Tutorials Point