Update core-java-modules/core-java-io-5/src/test/java/com/baeldung/outputstreamtobytearray/OutputStreamToByteArrayUnitTest.java
Co-authored-by: Liam Williams <liam.williams@zoho.com>
This commit is contained in:
parent
84bf4ee956
commit
dc98a1c302
|
@ -35,11 +35,8 @@ public class OutputStreamToByteArrayUnitTest {
|
|||
Path filePath = tempDir.resolve(fileName);
|
||||
|
||||
DrainableOutputStream drainableOutputStream = new DrainableOutputStream(new FileOutputStream(filePath.toFile()));
|
||||
|
||||
try {
|
||||
try (drainableOutputStream) {
|
||||
drainableOutputStream.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
} finally {
|
||||
drainableOutputStream.close();
|
||||
}
|
||||
|
||||
byte[] writtenData = drainableOutputStream.toByteArray();
|
||||
|
|
Loading…
Reference in New Issue