File f = null;
String name = null;
synchronized (this) {
if (nextFile >= inputFiles.size()) {
// exhausted files, start a new round, unless forever set to false.
if (!forever) {
throw new NoMoreDataException();
}
nextFile = 0;
iteration++;
}
f = (File) inputFiles.get(nextFile++);
name = f.getCanonicalPath()+"_"+iteration;
}
BufferedReader reader = new BufferedReader(new FileReader(f));
String line = null;
//First line is the date, 3rd is the title, rest is body
String dateStr = reader.readLine();
reader.readLine();//skip an empty line
String title = reader.readLine();
reader.readLine();//skip an empty line
StringBuffer bodyBuf = new StringBuffer(1024);
while ((line = reader.readLine()) != null) {
bodyBuf.append(line).append(' ");
}
reader.close();
addBytes(f.length());
Date date = dateFormat.parse(dateStr.trim());
return new DocData(name, bodyBuf.toString(), title, null, date);