I have the following code, but I'm not sure that i'm doing everything correctly in terms of efficiency/flushing/closing streams. Some advice would greatly help, thank you
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();
}
}