Code import java.io.*; import java.util.*; class Record { private int id; private String name; public Record(int id, String name) { setID(id); setName(name); } public void setID(int id) { this.id= id; } public void setName(String name) { if (name == null) this.name = ""; else this.name = name; } public int getID() { return id; } public String getName() { return name; } public String toString() { return String.format("%04d-> %s", id, name); } } public class TestSeq2 { public static void main(String[] args) { Scanner in = null; int readCount = 0; int writeCount = 0; System.out.printf("Records found in file:\n"); try { in = new Scanner(new File("records.txt")); while (in.hasNext()) { String linein = in.nextLine(); readCount++; String[] fields = linein.split(":"); if (fields.length != 2) { System.err.println("Error: Invalid record in file"); System.err.println(" * * * " + linein); } else { try { int id = Integer.parseInt(fields[0]); System.out.println(new Record(id, fields[1])); writeCount++; } catch (NumberFormatException e2) { System.out.println("Error: Invalid ID number found in file"); } } } } catch (Exception e1) { System.err.println(e1.getMessage()); } if (in != null) in.close(); System.out.println("\nRecords read: " + readCount); System.out.println("Records written: " + writeCount); } }