Source:
public ProjectSubmission parse() { projectSubmission = new ProjectSubmission(); String fileContents=null; try { while((fileContents= bufferedReader.readLine()) !=null) { fileContents=fileContents.trim(); if(fileContents.contains("CS410J")){ String[] splitContent=fileContents.split(Pattern.quote(".")); projectSubmission.setProjectName(splitContent[splitContent.length -1]); projectSubmission.setStudentId(splitContent[splitContent.length -2]); } if(fileContents.contains("Submitted by")){ String splitContent=fileContents.split("Submitted by "); projectSubmission.setStudentName(splitContent[splitContent.length -1]); } if(fileContents.contains("Submitted on")){ String splitContent=fileContents.split("Submitted on "); projectSubmission.setSubmissionTime(parseSubmissionTime(splitContent[splitContent.length -1])); } if(fileContents.contains("Graded on")){ String splitContent=fileContents.split("Graded on"); projectSubmission.setGradedTime(parseGradingTime(splitContent[splitContent.length -1].trim())); } if(fileContents.contains("out of")){ String splitContent=fileContents.split("out of"); String keyword="out of"; String awardedPoints=fileContents.substring(0, fileContents.indexOf(keyword)); if(!awardedPoints.isEmpty() && awardedPoints != "") { double specifiedGrade = Double.parseDouble(awardedPoints); projectSubmission.setScore(specifiedGrade); } projectSubmission.setTotalPoints(Double.parseDouble(splitContent[splitContent.length -1].trim())); } } } catch (IOException e) { e.printStackTrace(); } catch(ParseException pe) { logger.error("While Parsing the Date"+ pe); } return projectSubmission; }

Target:
public ProjectSubmission parse() throws ParseException, IOException, InvalidFileContentException { projectSubmission = new ProjectSubmission(); String fileContents=null; while((fileContents= bufferedReader.readLine()) !=null) { fileContents=fileContents.trim(); if(fileContents.contains("CS410J")){ String[] splitContent=fileContents.split(Pattern.quote(".")); projectSubmission.setProjectName(splitContent[splitContent.length -1]); projectSubmission.setStudentId(splitContent[splitContent.length -2]); } if(fileContents.contains(SUBMITTEDBY)){ String splitContent=fileContents.split(SUBMITTEDBY); projectSubmission.setStudentName(splitContent[splitContent.length -1].trim()); } if(fileContents.contains(SUBMITTEDON)){ String splitContent=fileContents.split(SUBMITTEDON); projectSubmission.setSubmissionTime(parseSubmissionTime(splitContent[splitContent.length -1].trim())); } if(fileContents.contains(GRADEDON)){ String splitContent=fileContents.split(GRADEDON); projectSubmission.setGradedTime(parseGradingTime(splitContent[splitContent.length -1].trim())); } if(fileContents.contains("out of")){ Pattern rightpattern = Pattern.compile("(?<=out of).*"); Pattern leftpattern=Pattern.compile(".*(?=out of)"); Matcher rightmatcher = rightpattern.matcher(fileContents); Matcher leftmatcher = leftpattern.matcher(fileContents); if (rightmatcher.find()) { projectSubmission.setTotalPoints(Double.parseDouble(rightmatcher.group().trim())); } else { throw new InvalidFileContentException("Not able to retrieve Total Points"); } if(leftmatcher.find()){ projectSubmission.setScore(Double.parseDouble(leftmatcher.group().trim())); } else { throw new InvalidFileContentException("Not able to retrieve the Score"); } } } return projectSubmission; }