I am attempting to access two string values within a simulation.log file and convert the two values to a type long. This is an example of the log file:
When I attempt to access the strings it is telling myself the are empty values. The error I am getting is:
My code is as follows (I understand the statement is not fully closed):
File file = new File(simulationLogDir + "/simulation.log");
FileReader simulationLogReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(simulationLogReader);
StringBuffer stringBuffer = new StringBuffer();
String line;
while ((line = bufferedReader.readLine()) != null) {
String[] fields = line.split("\t");
long responseTime = Long.parseLong(fields[5]) - Long.parseLong(fields[4]);
if (line.startsWith("REQUEST")) {
if (fields[7].equals("OK")) {
addPassedTest(fields[1], new Request(fields[4],responseTime, fields[7]));
}
Each line in the simulation log is separated by tabbed spaces so the fields array separates each string.