我有以下代码,但我不确定我是否在效率/刷新/关闭流方面做得正确。一些建议会很有帮助,谢谢
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file, true));
byte[] buf = new byte[32 * 1024]; // should this be 32KB?
while ((in.read(buf)) > 0) {
out.write(buf);
}
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null)
out.close();
if (in != null)
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}