内存操作流一般用来操作临时数据
操作字节数组
ByteArrayInputStream(Byte[] b)
ByteArrayOutputStream()
package com.baidu.io;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class DomeByteArray {
public static <Char> void main(String[] args) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
baos.write("h555".getBytes("UTF-8"));
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
int ch;
while ((ch= bais.read()) != -1) {
System.out.println((char)ch);
}
//关闭流
bais.close();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
操作字符数组
CharArrayReader
CharArrayOutputWriter
操作字符串
StringReader
StringWriter