Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.