mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 01:26: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
|
||||
public void testScreenshot() throws Exception {
|
||||
JadbDevice any = jadb.getAnyDevice();
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(temporaryFolder.newFile("screenshot.png"));
|
||||
try (FileOutputStream outputStream = new FileOutputStream(temporaryFolder.newFile("screenshot.png"))) {
|
||||
InputStream stdout = any.executeShell("screencap", "-p");
|
||||
Stream.copy(stdout, outputStream);
|
||||
} finally {
|
||||
if (outputStream != null) outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,9 @@ public class AdbOutputStreamFixture {
|
||||
|
||||
private byte[] passthrough(byte[] input) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
OutputStream sut = new AdbFilterOutputStream(output);
|
||||
try {
|
||||
sut.write(input);
|
||||
sut.flush();
|
||||
} finally {
|
||||
sut.close();
|
||||
try (OutputStream sut = new AdbFilterOutputStream(output)) {
|
||||
sut.write(input);
|
||||
sut.flush();
|
||||
}
|
||||
return output.toByteArray();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user