line = br.readLine();
} catch (IOException ex) {
Logger.getLogger(SrtParser.class.getName()).log(Level.SEVERE, null, ex);
}
Caption caption = null;
int lineNumber = 0;
while(line != null){
if (line.matches("[0-9]+:[0-9]+:[0-9]+,[0-9]+\\s-->\\s[0-9]+:[0-9]+:[0-9]+,[0-9]+")) {
long startTime = Utils.dateParseRegExp(line.split("\\s-->\\s")[0]);
long endTime = Utils.dateParseRegExp(line.split("\\s-->\\s")[1]);
caption = new Caption(startTime, endTime);
caption.setNumericCounter(lineNumber);
} else if (line.matches("[0-9]+") && caption == null) {
lineNumber = Integer.parseInt(line);
} else if (line.matches(".+")) {
if (caption != null) {
caption.setContents(line);
}
} else {
if (caption != null) {
subs.put(caption, caption.getNumericCounter());
caption = null;
}
}
try {
line = br.readLine();
} catch (IOException ex) {
Logger.getLogger(SrtParser.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (caption != null) {
subs.put(caption, caption.getNumericCounter());
}
return subs;
}