2.1 StringReader的用法
StringReader是Reader的继承类,从字面上就可看出,它是专门处理字符串的。
例:2.1.1
import java.io.*;
public class TestMark_to_win {
public static void main(String args[]) throws Exception {
// /from multiline string to StringReader, then to console
String s, s1 = new String();
s = "你们" + "他们a我们" + "\n";
System.out.println(s);
/* A character stream whose source is a string. */
StringReader in2 = new StringReader(s);
int c;
/*in2.read() Read a single character,(qixy: two bytes 或1个字节, so can handle chinese). or -1 if the end of the stream has been reached. Returns: The character read */
while ((c = in2.read()) != -1) {
System.out.println((char) c);
}
}
}
更多请见:https://blog.csdn.net/qq_44639795/article/details/102608658