Skip to content

Commit aef266a

Browse files
dfa1claude
andcommitted
docs(tutorial): close output stream in decompress example
transferTo already loops to EOF; the fix is managing the destination stream in try-with-resources so it flushes and closes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6c3f14a commit aef266a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

docs/tutorial.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ try (var out = new ZstdOutputStream(Files.newOutputStream(packed), 9)) {
7171
Files.copy(source, out);
7272
}
7373

74-
// decompress as you read it back
75-
try (var in = new ZstdInputStream(Files.newInputStream(packed))) {
76-
in.transferTo(Files.newOutputStream(restored));
74+
// decompress as you read it back (transferTo loops internally until EOF)
75+
try (var in = new ZstdInputStream(Files.newInputStream(packed));
76+
var out = Files.newOutputStream(restored)) {
77+
in.transferTo(out);
7778
}
7879
```
7980

0 commit comments

Comments
 (0)