Last active
January 7, 2019 00:06
-
-
Save stuart-marks/7c76280d2eaeca45ef1d1a602740bfeb to your computer and use it in GitHub Desktop.
Processing Large Files in Java, Variation 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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