Code Room
Code reviewMediumcr-g607
Subject Storage resource leakLevel Mid–Senior~18 minCommon in Storage & CDN interviewsIndustries Software development

Question

Review this Java method that copies log files.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
public void archiveLogs(List<File> logs, File destDir) throws IOException {    for (File log : logs) {        FileInputStream in = new FileInputStream(log);        File out = new File(destDir, log.getName() + ".bak");        FileOutputStream os = new FileOutputStream(out);        byte[] buf = new byte[8192];        int n;        while ((n = in.read(buf)) != -1) {            os.write(buf, 0, n);        }        os.close();        in.close();    }}
Run or narrate your approach, then ask the coach.