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:
DiegoMarti2 2023-12-11 23:08:59 +02:00 committed by GitHub
parent 84bf4ee956
commit dc98a1c302
1 changed files with 1 additions and 4 deletions

View File

@ -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();