字符流,字符流的缓冲区,序列流
来源:互联网 发布:千牛mac版使用 编辑:程序博客网 时间:2024/05/08 17:15
Reader reader = new FileReader(path1);
Writer writer = new FileWriter(path2);
Reader read = new FileReader(path);
BufferedReader br = new BufferedReader(read);
//合并两个流
private static void testSequenceInputStream() throws IOException {
FileInputStream fis1 = new FileInputStream(“c:\a.txt”);
FileInputStream fis2 = new FileInputStream(“c:\b.txt”);
SequenceInputStream s1 = new SequenceInputStream(fis1, fis2);
int len = 0;
byte[] byt = new byte[1024];
FileOutputStream fos = new FileOutputStream(“c:\z.txt”);
while ((len = s1.read(byt)) != -1) {
fos.write(byt, 0, len);
}
s1.close();
}
//合并多个流
public static void testSequenceInputStream() throws Exception {
InputStream in1 = new FileInputStream(“c:/a.txt”);
InputStream in2 = new FileInputStream(“c:/b.txt”);
InputStream in3 = new FileInputStream(“c:/c.txt”);
LinkedHashSet set = new LinkedHashSet();
set.add(in1);
set.add(in2);
set.add(in3);
final Iterator iter = set.iterator();
SequenceInputStream sin = new SequenceInputStream(
new Enumeration() {
@Override
public boolean hasMoreElements() {
return iter.hasNext();
}
@Override
public InputStream nextElement() {
return iter.next();
}
});
FileOutputStream out = new FileOutputStream(“c:/z.txt”);
for (int b = -1; (b = sin.read()) != -1;) {
out.write(b);
}
sin.close();
out.close();
}
- 字符流,字符流的缓冲区,序列流
- 字符流的缓冲区
- IO_02_字符流的缓冲区
- 字符流缓冲区
- 自定义字符流缓冲区
- 字符流缓冲区
- 字符流以及字符流缓冲区实例
- 黑马程序员_字符流的缓冲区
- 字符流缓冲区实现文件的读取
- 字符流的缓冲区和装饰模式
- 字符流缓冲区:BufferedWriter,BufferedReader
- Java IO 字符流 缓冲区
- 字符流(缓冲区问题)
- Java精选笔记_IO流(字符输入输出流、字符文件输入输出流、字符流的缓冲区)
- 黑马程序员--IO流概述、字符流、字符流缓冲区
- IO技术(三)字符流和字符缓冲区
- java 字节流与字符流的区别(缓冲区)
- 黑马程序员 字节流和字符流缓冲区的对比
- 诗词
- HttpServletRequest的部分方法解析
- Pat(A) 1070. Mooncake (25)
- Python整行输入
- Unity处女作学习总结--第四、五天
- 字符流,字符流的缓冲区,序列流
- 分类问题的数学定义
- 动态规划——硬币问题
- Python判断是否是闰年
- 归并排序模板
- Oracle DML语言
- Sublime 中快速打开网页
- aop 与 ioc
- 微信开发之微信授权