笔记 第1章 流与文件(2) 组合流过滤器_p2p

 1.1.3 组合流过滤器

节点流:基本的输入输出流

处理流:包装基本流,进行输入输出的叫做处理流

通常两者间的区别是,节点流创建容易,处理步骤复杂;处理流创建麻烦,处理步骤容易。

❤🧡💛💚💙💜🤎🖤❤🧡💛💚💙💜🤎🖤❤🧡💛💚💙💜🤎🖤

import java.io.*;

public class Main {
public static void main(String[] args){
BufferedReader br = null;
BufferedWriter bw = null;
try {
String str = "Returns <tt>true</tt> if this map maps one or more keys to the\n" +
"specified value. More formally, returns <tt>true</tt> if and only if\n" +
"this map contains at least one mapping to a value <tt>v</tt> such that\n" +
"<tt>(value==null ? v==null : value.equals(v))</tt>. This operation\n" +
"will probably require time linear in the map size for most\n" +
"implementations of the <tt>Map</tt> interface.";

String[] parts = str.split("\n");
bw = new BufferedWriter(new FileWriter("a.properties"));
for(String part:parts){
bw.write(part);
bw.write("\n");
}
bw.flush();

br = new BufferedReader(new FileReader("a.properties"));
String line = null;
while((line=br.readLine())!=null){
System.out.println(line);
}

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(br!=null){
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}

if(bw!=null){
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

}

}

❤🧡💛💚💙💜🤎🖤❤🧡💛💚💙💜🤎🖤❤🧡💛💚💙💜🤎🖤

输出:

结果:

🚗🚓🚕🛺🚙🚌🚐🚎🚑🚒🚚🚛🚜🚘🚔🚖🚍🦽🦼🛹🚲🛴🛵🏍

笔记 第1章 流与文件(2) 组合流过滤器_处理流_02

🚗🚓🚕🛺🚙🚌🚐🚎🚑🚒🚚🚛🚜🚘🚔🚖🚍🦽🦼🛹🚲🛴🛵🏍

笔记 第1章 流与文件(2) 组合流过滤器_输入输出流_03

 相关内容:选择 《Java核心技术 卷1》查找相关笔记

评论🌹点赞👍收藏✨关注👀,是送给作者最好的礼物,愿我们共同学习,一起进步

公众号 钰娘娘知识汇总