in struts2-secure-jakarta-stream-multipart-parser-plugin/src/main/java/org/apache/struts/extras/SecureJakartaStreamMultiPartRequest.java [463:491]
private boolean streamFileToDisk(FileItemStream itemStream, File file) throws IOException {
boolean result = false;
InputStream input = itemStream.openStream();
OutputStream output = null;
try {
output = new BufferedOutputStream(new FileOutputStream(file), bufferSize);
byte[] buffer = new byte[bufferSize];
LOG.debug("Streaming file using buffer size #0.", bufferSize);
for (int length = 0; ((length = input.read(buffer)) > 0); )
output.write(buffer, 0, length);
result = true;
} finally {
if (output != null) {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}