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 #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: | 778 / 191 | 
| Referenced in: | [show references] |