Skip to content

Commit 3597aef

Browse files
authored
Update DownloadFileEx.java
1 parent da70d15 commit 3597aef

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

net/channel/DownloadFileEx.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ public static void main(String[] args) throws IOException {
1515
var myUrl = new URL(remoteFileName);
1616

1717
try (var rbc = Channels.newChannel(myUrl.openStream())) {
18-
try (var fos = new FileOutputStream(localFileName)) {
1918

20-
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
19+
try (var fos = new FileOutputStream(localFileName);
20+
var fch = fos.getChannel()) {
21+
22+
fch.transferFrom(rbc, 0, Long.MAX_VALUE);
2123
}
2224
}
2325
}
2426
}
27+
28+

0 commit comments

Comments
 (0)