Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte b[];
- sock.getInputStream().read(b);
- byte b[] = byte[BIG_ENOUGH];
- int nosRead = sock.getInputStream().read(b);
- byte[] resultBuff = new byte[0];
- byte[] buff = new byte[1024];
- int k = -1;
- while((k = sock.getInputStream().read(buff, 0, buff.length)) > -1) {
- byte[] tbuff = new byte[resultBuff.length + k]; // temp buffer size = bytes already read + bytes last read
- System.arraycopy(resultBuff, 0, tbuff, 0, resultBuff.length); // copy previous bytes
- System.arraycopy(buff, 0, tbuff, resultBuff.length, k); // copy current lot
- resultBuff = tbuff; // call the temp buffer as your result buff
- }
- System.out.println(resultBuff.length + " bytes read.");
- return resultBuff;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte buf = new byte[4096];
- while(true) {
- int n = is.read(buf);
- if( n < 0 ) break;
- baos.write(buf,0,n);
- }
- byte data[] = baos.toByteArray();
- BufferedInputStream buf = new BufferedInputStream(is);
- int size = buf.available();
Add Comment
Please, Sign In to add comment