From 45c67bad0ab5c505aef7e5958054cf83c150eb3d Mon Sep 17 00:00:00 2001 From: Jano Svitok Date: Mon, 6 Aug 2018 10:29:19 +0200 Subject: [PATCH] Use try-with-resources for reading/writing files --- src/se/vidstige/jadb/JadbDevice.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/se/vidstige/jadb/JadbDevice.java b/src/se/vidstige/jadb/JadbDevice.java index f3ac12e..2000f63 100644 --- a/src/se/vidstige/jadb/JadbDevice.java +++ b/src/se/vidstige/jadb/JadbDevice.java @@ -163,9 +163,9 @@ public class JadbDevice { } public void push(File local, RemoteFile remote) throws IOException, JadbException { - FileInputStream fileStream = new FileInputStream(local); - push(fileStream, local.lastModified(), getMode(local), remote); - fileStream.close(); + try (FileInputStream fileStream = new FileInputStream(local)) { + push(fileStream, local.lastModified(), getMode(local), remote); + } } public void pull(RemoteFile remote, OutputStream destination) throws IOException, JadbException { @@ -177,9 +177,9 @@ public class JadbDevice { } public void pull(RemoteFile remote, File local) throws IOException, JadbException { - FileOutputStream fileStream = new FileOutputStream(local); - pull(remote, fileStream); - fileStream.close(); + try (FileOutputStream fileStream = new FileOutputStream(local)) { + pull(remote, fileStream); + } } private void send(Transport transport, String command) throws IOException, JadbException {