public String getText() {
String lineEnd = System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer sb = new StringBuffer();
Reader reader = null;
BufferedReader br = null;
try {
if (encoding == null) {
reader = new FileReader(this);
} else {
reader = new InputStreamReader(new FileInputStream(this), encoding);
}
br = new BufferedReader(reader);
String line = "NOTNULL"; //$NON-NLS-1$
while (line != null) {
line = br.readLine();
if (line != null) {
sb.append(line + lineEnd);
}
}
} catch (IOException ioe) {
log.error("", ioe); //$NON-NLS-1$
} finally {
JOrphanUtils.closeQuietly(br); // closes reader as well
}
return sb.toString();
}
Read the whole file content and return it as a string. |