Guest User

Untitled

a guest
Jul 15th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. byte b[];
  2. sock.getInputStream().read(b);
  3.  
  4. byte b[] = byte[BIG_ENOUGH];
  5. int nosRead = sock.getInputStream().read(b);
  6.  
  7. byte[] resultBuff = new byte[0];
  8. byte[] buff = new byte[1024];
  9. int k = -1;
  10. while((k = sock.getInputStream().read(buff, 0, buff.length)) > -1) {
  11. byte[] tbuff = new byte[resultBuff.length + k]; // temp buffer size = bytes already read + bytes last read
  12. System.arraycopy(resultBuff, 0, tbuff, 0, resultBuff.length); // copy previous bytes
  13. System.arraycopy(buff, 0, tbuff, resultBuff.length, k); // copy current lot
  14. resultBuff = tbuff; // call the temp buffer as your result buff
  15. }
  16. System.out.println(resultBuff.length + " bytes read.");
  17. return resultBuff;
  18.  
  19. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  20.  
  21. byte buf = new byte[4096];
  22. while(true) {
  23. int n = is.read(buf);
  24. if( n < 0 ) break;
  25. baos.write(buf,0,n);
  26. }
  27.  
  28. byte data[] = baos.toByteArray();
  29.  
  30. BufferedInputStream buf = new BufferedInputStream(is);
  31. int size = buf.available();
Add Comment
Please, Sign In to add comment