标签:exce ast 获取数据 string rem puts 取数 log throws
内存操作流:用于处理临时存储信息的,程序结束,数据就从内存消失。
package cn.idcast;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/*
* 内存操作流:用于处理临时存储信息的地方,程序结束,数据就从内存消失
*
* 字节数组 不需要释放资源,系统默认
* ByteArrayInputStream
* ByteArrayOutputStrem 可以使用toByteArray()方法获取数据
* 字节数组
* CharArrayReader
* CharArrayWriter 可以使用toCharArray()方法获取数据
* 字符数组
* StringReader
* StringWriter
*/
public class Day1 {
public static void main(String[] args) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int x=0;x<10;x++) {
baos.write(("hello"+x).getBytes());
}
byte[] bys =baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bys);
int by = 0;
while((by=bais.read())!=-1) {
System.out.print((char)by);
}
}
}
标签:exce ast 获取数据 string rem puts 取数 log throws
原文地址:http://www.cnblogs.com/zengjiao/p/6360219.html