Code Room
Code reviewMedium
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.
Learn the concepts
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.