this.getLogger().debug("BEGIN getContentFromFile filename=" + filename +
", typeParams="+typeParameters+
", parameters="+resourceParameters);
}
String content;
Source input = null;
try {
input = this.resolver.resolve(filename);
String absolutePath = input.getSystemId();
if (absolutePath.startsWith("file:") == false) {
throw new ProcessingException("Saving to " + filename + " is not possible.");
}
File file = new File(absolutePath.substring("file:".length()));
byte[] data = null;
InputStream fis = new FileInputStream(file);
int available;
byte[] tempData;
byte[] copyData;
do {
available = 1024;
tempData = new byte[available];
available = fis.read(tempData, 0, available);
if (available > 0) {
copyData = new byte[(data == null ? 0 : data.length) + available];
if (data != null) {
System.arraycopy(data, 0, copyData, 0, data.length);
}
System.arraycopy(tempData, 0, copyData, (data == null ? 0 : data.length), available);
data = copyData;
}
} while (available > 0);
fis.close();
content = (data == null ? "" : new String(data));
} catch (FileNotFoundException local) {
throw new ResourceNotFoundException("File not found '" + filename + "'", local);
} finally {
if (input != null) input.recycle();
input = null;
}
if (this.getLogger().isDebugEnabled() == true) {
this.getLogger().debug("END getContentFromFile content="+content);
}