public static byte[] loadBinaryPage(URLConnection con) throws IOException {
//setHeaders(con);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
InputStream inputStream = con.getInputStream();
int n = 0;
while (true) {
int ch = inputStream.read();
if (ch < 0)
break;
buf.write(ch);
if (++n % 100000 == 0)
System.err.println(" " + n + " bytes loaded.");
}
inputStream.close();
return buf.toByteArray();
}
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: | 766 / 1433 |
| Referenced in: | [show references] |