Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stuart-marks/7c76280d2eaeca45ef1d1a602740bfeb to your computer and use it in GitHub Desktop.
Save stuart-marks/7c76280d2eaeca45ef1d1a602740bfeb to your computer and use it in GitHub Desktop.
Processing Large Files in Java, Variation 1
--- ReadFileJavaApplicationBufferedReader0.java
+++ ReadFileJavaApplicationBufferedReader1.java
@@ -57,8 +57,8 @@
// System.out.println(readLine);
// get all the names
- String array1[] = readLine.split("\\s*\\|\\s*");
- String name = array1[7];
+ String array1[] = readLine.split("\\|", 9);
+ String name = array1[7].strip();
names.add(name);
if(indexes.contains(lines)){
System.out.println("Name: " + names.get(lines - 1) + " at index: " + (lines - 1));
@@ -80,7 +80,7 @@
}
}
- String rawDate = array1[4];
+ String rawDate = array1[4].strip();
String month = rawDate.substring(4,6);
String year = rawDate.substring(0,4);
String formattedDate = month + "-" + year;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment