Use try-with-resources for reading/writing files

This commit is contained in:
Jano Svitok 2018-08-06 10:29:19 +02:00
parent cb989acfa9
commit 45c67bad0a

View File

@ -163,9 +163,9 @@ public class JadbDevice {
} }
public void push(File local, RemoteFile remote) throws IOException, JadbException { public void push(File local, RemoteFile remote) throws IOException, JadbException {
FileInputStream fileStream = new FileInputStream(local); try (FileInputStream fileStream = new FileInputStream(local)) {
push(fileStream, local.lastModified(), getMode(local), remote); push(fileStream, local.lastModified(), getMode(local), remote);
fileStream.close(); }
} }
public void pull(RemoteFile remote, OutputStream destination) throws IOException, JadbException { 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 { public void pull(RemoteFile remote, File local) throws IOException, JadbException {
FileOutputStream fileStream = new FileOutputStream(local); try (FileOutputStream fileStream = new FileOutputStream(local)) {
pull(remote, fileStream); pull(remote, fileStream);
fileStream.close(); }
} }
private void send(Transport transport, String command) throws IOException, JadbException { private void send(Transport transport, String command) throws IOException, JadbException {