所以最近我学会了使用流,包括输入和输出来学习,这样我就可以从文件中读取并写入一个文件。但是我的老师有时决定使用缓冲,有时他不这样做。就像在这种情况下,病态发布代码。你们明白为什么他在这种情况下没有放置缓冲输出流吗?
public void writePrimes2(String filename) throws IOException {
try(ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(filename))){
os.writeObject(primes);
os.flush();
}
}
交互式爱情
弑天下
相关分类