在下面的代码中,ByteArrayOutputStream
的数据在RAM或硬盘上存储在哪里?ByteArrayOutputStream的数据存储在RAM或硬盘上?
ByteArrayOutputStream bOutput = new ByteArrayOutputStream(12);
while(bOutput.size()!= 10) {
// Gets the inputs from the user
bOutput.write("hello".getBytes());
}
ByteArrayOutputStream类流在内存[ram]中创建一个缓冲区。对于性能严重的代码,请尝试使用ByteBuffer而不是ByteArrayOutputStream。如果一起使用同步和ByteArrayOutputStream,则摆脱同步部分。 – Vaibs