1 | public static byte[] loadBinaryPage(URLConnection con) throws IOException { |
2 | //setHeaders(con); |
3 | ByteArrayOutputStream buf = new ByteArrayOutputStream(); |
4 | InputStream inputStream = con.getInputStream(); |
5 | int n = 0; |
6 | while (true) { |
7 | int ch = inputStream.read(); |
8 | if (ch < 0) |
9 | break; |
10 | buf.write(ch); |
11 | if (++n % 100000 == 0) |
12 | System.err.println(" " + n + " bytes loaded."); |
13 | } |
14 | inputStream.close(); |
15 | return buf.toByteArray(); |
16 | } |
Began life as a copy of #2000465
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #2000466 |
Snippet name: | loadBinaryPage with progress monitoring on System.err, overrides #2000465 |
Eternal ID of this version: | #2000466/1 |
Text MD5: | 1e40d6e4130981b81cce1b27b1baf02f |
Author: | stefan |
Category: | |
Type: | New Tinybrain snippet |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-07-26 20:27:59 |
Source code size: | 504 bytes / 16 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 546 / 1378 |
Referenced in: | [show references] |