Skip to content

Instantly share code, notes, and snippets.

@dan-dm
Last active May 16, 2020 14:42
Show Gist options
  • Save dan-dm/a4298e7a23ab483fc20ad3c6cb7b195e to your computer and use it in GitHub Desktop.
Save dan-dm/a4298e7a23ab483fc20ad3c6cb7b195e to your computer and use it in GitHub Desktop.
Created with Copy to Gist
try (Scanner scanner = new Scanner(Paths.get("records.txt"))) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
String[] parts = line.split(",");
String name = parts[0];
int age = Integer.valueOf(parts[1]);
System.out.println("Name: " + name);
System.out.println("Age: " + age);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment