package test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class ByteArrayReview {
/**
* 内存字节操作流:
* 内存字节输入流:ByteArrayInputStream 将内容写入到内存中去
* 内存字节输出流:ByteArrayOutputStream 将内容从内存中写出去
*
*/
public static void main(String[] args) throws IOException {
//创建一个内存字节输入流对象与一个内存字节输出流对象
ByteArrayInputStream bis = new ByteArrayInputStream("hello~".getBytes());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int temp = 0;
if ((temp = bis.read(b)) != -1) {
//将读进的内容以大写的方式写出
bos.write(Character.toUpperCase((char) temp));
}
String s = bos.toString();//取出内容
bos.close();//关闭无效
bis.close();//关闭无效
System.out.println(s);
}
}