Created
October 24, 2021 15:19
-
-
Save akwasiio/2f378e24c5e8b327fca27f1f05fe3dc7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static void ReadFile(String filePath) { | |
ArrayList<String> messageTypeList = new ArrayList<>(); | |
ArrayList<String> transactionTypeList = new ArrayList<>(); | |
ArrayList<String> responseCodeList = new ArrayList<>(); | |
ArrayList<String> systemTraceList = new ArrayList<>(); | |
try (BufferedReader oBufferedReader = new BufferedReader(new FileReader(filePath))) { | |
String strLine; | |
oBufferedReader.readLine(); // skips the first line | |
// | |
while ((strLine = oBufferedReader.readLine()) != null) { | |
String[] array = strLine.split(","); // split the line by comma | |
for (int i = 0; i < array.length; i++) { // loops through the resulting array from split operation | |
switch (i) { | |
case 0: | |
messageTypeList.add(array[i]); | |
break; | |
case 1: | |
transactionTypeList.add(array[i]); | |
break; | |
case 2: | |
responseCodeList.add(array[i]); | |
break; | |
case 3: | |
systemTraceList.add(array[i]); | |
break; | |
// and so on and so forth | |
default: | |
break; | |
} | |
} | |
} | |
System.out.println("Message Types: " + messageTypeList); | |
System.out.println("Transaction Types: " + transactionTypeList); | |
System.out.println("Response Codes: " + responseCodeList); | |
System.out.println("System Trace: " + systemTraceList); | |
} catch (IOException e) { | |
System.err.format("IOException %s%n", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment