public class test{
public static void main(String args[]) throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
String str = "hello,world";
output.write(str.getBytes()); //数据存储在在output里
//将数据写入到内存中
//InputStream input = new ByteArrayInputStream(output.toByteArray());
InputStream input = new ByteArrayInputStream("hello,world".getBytes());
int temp = 0;
while((temp=input.read())!=-1){ //从数据内存中读取数据
System.out.println((char)temp);
}
}
}