Review this generated order-import boundary before it handles uploaded files.
Read UTF-8 order lines, fail the whole import on the first invalid line, return a count only on success, preserve an I/O cause for the caller, and never expose the input path.
Java
static String importOrders(Path path) {
BufferedReader reader = null;
int imported = 0;
try {
reader = Files.newBufferedReader(path);
for (String line; (line = reader.readLine()) != null;) {
try {
save(parse(line));
imported++;
} catch (RuntimeException ignored) {}
}
return "Imported " + imported;
} catch (Exception error) {
return "Import failed: " + error;
} finally {
try { reader.close(); } catch (Exception ignored) {}
}
}
generated code is illustrative, not from any one model