}
try {
File outputFile = getFile(fileLocator);
FileChangeOutputStream outputStream = null;
try {
// throws IOException:
outputStream = new FileChangeOutputStream(outputFile);
FileSystemResourceHelper.transferData(source, outputStream);
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
} catch (IOException ioe) {
// Nothing can really be done at this point, and we don't bother reporting the error.
}
}
// If here, an exception was not thrown.
// If the file wasn't written, update the timestamp to provide a visible indication that the file data was processed.
// Note: don't do this in the try block since this call would have no effect while the output stream is open.
if (outputStream != null && !outputStream.isDifferent()) {
getFile(fileLocator).setLastModified(System.currentTimeMillis());
}
} finally {
source.close();
}