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 #2000463
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: | #2000465 |
| Snippet name: | loadBinaryPage with progress monitoring on System.err |
| Eternal ID of this version: | #2000465/1 |
| Text MD5: | dcb3b81bbce14a1cd603ec735d30304a |
| Author: | stefan |
| Category: | |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-07-26 20:26:45 |
| Source code size: | 502 bytes / 16 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 780 / 192 |
| Referenced in: | [show references] |