内存操作流
操作字节数组
ByteArrayInputStream
ByteArrayOutputStream
操作字符数组
CharArrayReader
CharArrayWrite
操作字符串
StringReader
StringWriter
内存操作流一般用于处理临时信息,因为不用保存,使用后就可以删除
public static void main(String[] args) throws Exception {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("/Users/yoofale/Desktop/haha.txt"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// 自定义缓冲区容器
byte[] buf=new byte[1024];
// 记录每次读取字节的长度
int len =-1;
while((len=bis.read(buf))!=-1){
baos.write(buf,0,len);
}
bis.close();
// 将字节数组中的字节取出来
byte[] byteArray = baos.toByteArray();
System.out.println(byteArray.length);
}
分割和组合文件
public class SplitAndGroupFileD