当前位置:   article > 正文

IO Stream Reading_server reponse :426 failure reading network stream

server reponse :426 failure reading network stream
  1. public static byte[] readInputStream(InputStream ins) {
  2. if (ins == null) {
  3. return null;
  4. }
  5. BufferedInputStream bis = new BufferedInputStream(ins);
  6. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  7. try {
  8. byte[] buffer = new byte[128];
  9. int n = -1;
  10. while ((n = bis.read(buffer)) != -1) {
  11. bos.write(buffer, 0, n);
  12. }
  13. } catch (IOException e) {
  14. e.printStackTrace();
  15. return null;
  16. } finally {
  17. if (bis != null) {
  18. try {
  19. bis.close();
  20. } catch (IOException e) {
  21. e.printStackTrace();
  22. }
  23. }
  24. }
  25. return bos.toByteArray();
  26. }

 
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/199941
推荐阅读
相关标签
  

闽ICP备14008679号