GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update OutputStreamToByteArrayUnitTest.java · edizor/tutorials@60198ce

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • core-java-modules/core-java-io-5/src/test/java/com/baeldung/outputstreamtobytearray
    • OutputStreamToByteArrayUnitTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎core-java-modules/core-java-io-5/src/test/java/com/baeldung/outputstreamtobytearray/OutputStreamToByteArrayUnitTest.java‎

Copy file name to clipboardExpand all lines: core-java-modules/core-java-io-5/src/test/java/com/baeldung/outputstreamtobytearray/OutputStreamToByteArrayUnitTest.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public void givenFileOutputStream_whenUsingFileUtilsToReadTheFile_thenReturnByte
2929

3030

3131
@Test
32-
public void givenFileOutputStream_whenUsingDrainableOutputStream_thenReturnByteArray(@TempDir Path tempDir) throws IOException {
32+
public void givenByteArrayOutputStream_whenUsingDrainableOutputStream_thenReturnByteArray() throws IOException {
3333
String data = "Welcome to Baeldung!";
34-
String fileName = "file.txt";
35-
Path filePath = tempDir.resolve(fileName);
3634

37-
DrainableOutputStream drainableOutputStream = new DrainableOutputStream(new FileOutputStream(filePath.toFile()));
35+
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
36+
DrainableOutputStream drainableOutputStream = new DrainableOutputStream(byteArrayOutputStream);
37+
3838
try (drainableOutputStream) {
3939
drainableOutputStream.write(data.getBytes(StandardCharsets.UTF_8));
4040
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.