Source:
<code>private File handleInputStreamMessage(final InputStream sourceFileInputStream, File originalFile, File tempFile, final File resultFile) throws IOException { final boolean append = FileExistsMode.APPEND.equals(this.fileExistsMode) || FileExistsMode.APPEND_NO_FLUSH.equals(this.fileExistsMode); if (append) { final File fileToWriteTo = this.determineFileToWrite(resultFile, tempFile); final FileState state = getFileState(fileToWriteTo, false); WhileLockedProcessor whileLockedProcessor = new WhileLockedProcessor(this.lockRegistry, fileToWriteTo.getAbsolutePath()) { @Override protected void whileLocked() throws IOException { <START> BufferedOutputStream bos = state != null ? state.stream : createOutputStream(fileToWriteTo, append); <END> try { byte[] buffer = new byte[StreamUtils.BUFFER_SIZE]; int bytesRead = -1; while ((bytesRead = sourceFileInputStream.read(buffer)) != -1) { bos.write(buffer, 0, bytesRead); } if (FileWritingMessageHandler.this.appendNewLine) { bos.write(LINE_SEPARATOR.getBytes()); } } finally { try { sourceFileInputStream.close(); } catch (IOException ex) { } try { if (state == null) { bos.close(); } else { state.lastWrite = System.currentTimeMillis(); } } catch (IOException ex) { } } } }; whileLockedProcessor.doWhileLocked(); cleanUpAfterCopy(fileToWriteTo, resultFile, originalFile); return resultFile; } else { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempFile), this.bufferSize); try { byte[] buffer = new byte[StreamUtils.BUFFER_SIZE]; int bytesRead = -1; while ((bytesRead = sourceFileInputStream.read(buffer)) != -1) { bos.write(buffer, 0, bytesRead); } if (this.appendNewLine) { bos.write(LINE_SEPARATOR.getBytes()); } bos.flush(); } finally { try { sourceFileInputStream.close(); } catch (IOException ex) { } try { bos.close(); } catch (IOException ex) { } } cleanUpAfterCopy(tempFile, resultFile, originalFile); return resultFile; } }</code><technical_language>IDEA this append argument is true. is if (append) { logic. Minor, of course, I IDE noise :smile:</technical_language>

Target:
private File handleInputStreamMessage(final InputStream sourceFileInputStream, File originalFile, File tempFile, final File resultFile) throws IOException { final boolean append = FileExistsMode.APPEND.equals(this.fileExistsMode) || FileExistsMode.APPEND_NO_FLUSH.equals(this.fileExistsMode); if (append) { final File fileToWriteTo = this.determineFileToWrite(resultFile, tempFile); final FileState state = getFileState(fileToWriteTo, false); WhileLockedProcessor whileLockedProcessor = new WhileLockedProcessor(this.lockRegistry, fileToWriteTo.getAbsolutePath()) { @Override protected void whileLocked() throws IOException { BufferedOutputStream bos = state != null ? state.stream : createOutputStream(fileToWriteTo, true); try { byte[] buffer = new byte[StreamUtils.BUFFER_SIZE]; int bytesRead = -1; while ((bytesRead = sourceFileInputStream.read(buffer)) != -1) { bos.write(buffer, 0, bytesRead); } if (FileWritingMessageHandler.this.appendNewLine) { bos.write(LINE_SEPARATOR.getBytes()); } } finally { try { sourceFileInputStream.close(); } catch (IOException ex) { } try { if (state == null || FileWritingMessageHandler.this.flushTask == null) { bos.close(); } else { state.lastWrite = System.currentTimeMillis(); } } catch (IOException ex) { } } } }; whileLockedProcessor.doWhileLocked(); cleanUpAfterCopy(fileToWriteTo, resultFile, originalFile); return resultFile; } else { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempFile), this.bufferSize); try { byte[] buffer = new byte[StreamUtils.BUFFER_SIZE]; int bytesRead = -1; while ((bytesRead = sourceFileInputStream.read(buffer)) != -1) { bos.write(buffer, 0, bytesRead); } if (this.appendNewLine) { bos.write(LINE_SEPARATOR.getBytes()); } bos.flush(); } finally { try { sourceFileInputStream.close(); } catch (IOException ex) { } try { bos.close(); } catch (IOException ex) { } } cleanUpAfterCopy(tempFile, resultFile, originalFile); return resultFile; } }