mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 17:46:47 +01:00
Convert to try-with-resources
This commit is contained in:
parent
bdbb454acb
commit
adb0cca09a
@ -111,13 +111,9 @@ public class RealDeviceTestCases {
|
|||||||
@Test
|
@Test
|
||||||
public void testScreenshot() throws Exception {
|
public void testScreenshot() throws Exception {
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
FileOutputStream outputStream = null;
|
try (FileOutputStream outputStream = new FileOutputStream(temporaryFolder.newFile("screenshot.png"))) {
|
||||||
try {
|
|
||||||
outputStream = new FileOutputStream(temporaryFolder.newFile("screenshot.png"));
|
|
||||||
InputStream stdout = any.executeShell("screencap", "-p");
|
InputStream stdout = any.executeShell("screencap", "-p");
|
||||||
Stream.copy(stdout, outputStream);
|
Stream.copy(stdout, outputStream);
|
||||||
} finally {
|
|
||||||
if (outputStream != null) outputStream.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,9 @@ public class AdbOutputStreamFixture {
|
|||||||
|
|
||||||
private byte[] passthrough(byte[] input) throws IOException {
|
private byte[] passthrough(byte[] input) throws IOException {
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
OutputStream sut = new AdbFilterOutputStream(output);
|
try (OutputStream sut = new AdbFilterOutputStream(output)) {
|
||||||
try {
|
|
||||||
sut.write(input);
|
sut.write(input);
|
||||||
sut.flush();
|
sut.flush();
|
||||||
} finally {
|
|
||||||
sut.close();
|
|
||||||
}
|
}
|
||||||
return output.toByteArray();
|
return output.toByteArray();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user