Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1008548 // loadBinaryPageSilently

JavaX fragment (include)

1  
static byte[] loadBinaryPageSilently(String url) ctex {
2  
  return loadBinaryPageSilently(openConnection(new URL(url)));
3  
}
4  
5  
static byte[] loadBinaryPageSilently(URLConnection con) ctex {
6  
  setHeaders(con);
7  
  ret loadBinaryPageSilently_noHeaders(con);
8  
}
9  
10  
static byte[] loadBinaryPageSilently_noHeaders(URLConnection con) ctex {
11  
  new ByteArrayOutputStream buf;
12  
  InputStream inputStream = con.getInputStream();
13  
  long len = 0;
14  
  try { len = con.getContentLength/*Long*/(); } catch (Throwable e) { printStackTrace(e); }
15  
  int n = 0;
16  
  while (true) {
17  
    int ch = inputStream.read();
18  
    if (ch < 0)
19  
      break;
20  
    buf.write(ch);
21  
  }
22  
  inputStream.close();
23  
  ret buf.toByteArray();
24  
}

Author comment

Began life as a copy of #1000837

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008548
Snippet name: loadBinaryPageSilently
Eternal ID of this version: #1008548/4
Text MD5: f81679db0e83f4da7228c2923e31e8d0
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-04 17:35:16
Source code size: 705 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 478 / 517
Version history: 3 change(s)
Referenced in: [show references]