if (charset == null) {
charset = "ISO-8859-1";
}
LineNumberReader rdr = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(resource.getData()),
charset));
Paragraph paragraph = textRecord.addParagraph(Paragraph.DEFAULT_SPACING);
for (String line; (line = rdr.readLine()) != null;) {
if (line.length() == 0) {
paragraph = textRecord.addParagraph(Paragraph.DEFAULT_SPACING);
} else {
int start = line.indexOf("http://");
if (start > -1) {
int end = line.indexOf(' ', start);
if (end == -1) {
end = line.length();
}
String url = line.substring(start, end);
paragraph.addLinkStart(url);
paragraph.addPreformattedText(url);
paragraph.addLinkEnd();
} else {
paragraph.addPreformattedText(line);
}
paragraph.addNewline();
}
}
pluckerDocument.addRecord(textRecord);
} catch (IOException e) {
throw new HandlingException(e);