IO系统结构思维导图
第一部分 字符流
1、字符流读String 缓存流 常用 (StringReader/BufferedReader)
/**
* 字符流读String 缓存流 常用
*/
public static void readFileStringbuf() throws Exception{
Reader reader = new StringReader("eddydasdsa\r\nddsadsad "); //该构造器是纯文本,如何是路径不会解析文件内容
BufferedReader buf = new BufferedReader(reader);
String line = null;
StringBuilder builder = new StringBuilder("");
while (null !=(line = buf.readLine())){
builder.append(line);
}
System.out.println(builder.toString());
buf.close();
reader.close();
}
2、字符流读文本文件 缓存流 常用 (BufferedReader)
/**
* 字符流读文本文件 缓存流 常用
*/
public static void readFileSFbuf() throws Exception{
Reader reader = new FileReader("D:\\file\\text\\test.txt");
BufferedReader buf = new BufferedReader(reader);
String line = null;
StringBuilder builder = new StringBuilder("");
while (null !=(line = buf.readLine())){
builder.append(line);
}
System.out.println(builder.toString());
buf.close();
reader.close();
}
3、字