Skip to content

Commit

Permalink
Use 1 try-with-resources instead of multiple ones
Browse files Browse the repository at this point in the history
  • Loading branch information
sakama committed Nov 7, 2017
1 parent ba43aba commit 5e6e74f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/org/embulk/output/sftp/SftpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,13 @@ public Void uploadFile(final File localTempFile, final String remotePath)
@Override
public Void call() throws IOException
{
FileObject remoteFile = newSftpFile(getSftpFileUri(remotePath));
logger.info("new sftp file: {}", remoteFile.getPublicURIString());
try (BufferedOutputStream outputStream = new BufferedOutputStream(remoteFile.getContent().getOutputStream())) {
try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(localTempFile))) {
IOUtils.copy(inputStream, outputStream);
}
try (FileObject remoteFile = newSftpFile(getSftpFileUri(remotePath));
BufferedOutputStream outputStream = new BufferedOutputStream(remoteFile.getContent().getOutputStream());
BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(localTempFile))
) {
logger.info("new sftp file: {}", remoteFile.getPublicURIString());
IOUtils.copy(inputStream, outputStream);
}
remoteFile.close();
return null;
}

Expand Down

0 comments on commit 5e6e74f

Please sign in to comment.