public static void write(){
String text="abcdefg";
ByteArrayInputStream bais=new ByteArrayInputStream(text.getBytes());
int n=bais.read();
while(n!=-1){
System.out.print((char)n);
n=bais.read();
}
try {
if(bais!=null){
bais.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}我的疑惑如下:
整个Java代码不都是在内存中运行的吗?那个整个Java程序不就是内存的一部分?为什么还会有内存流(用来传递程序和内存之间的数据)这一说?
请大神解释一下,在此谢过啦!
注:和什么堆内存、栈内存等没有关系,真的是不理解内存与程序的关系。
qq_阳光下的海风_0
阿旭_
随时随地看视频慕课网APP
相关分类