try { while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes;
byte[] buffer = new byte[65536]; // 64K int read = -1; while ((read = in.read(buffer)) >= 0) { out.write(buffer, 0, read);
while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes;
/** * Calls {@link #read()} repeatedly until the end of stream is reached or <var>len</var> bytes are read. Returns number of * bytes read into array or -1 if end of stream is encountered. * * @param dest array to hold values * @param off offset for array * @param len max number of bytes to read into array * @return bytes read into array or -1 if end of stream is encountered. * @throws IOException * @since 1.3 */ @Override public int read( byte[] dest, int off, int len ) throws IOException { int i; int b; for (i = 0; i < len; i++) { b = read(); // if( b < 0 && i == 0 ) // return -1; if (b >= 0) dest[off + i] = (byte)b; else if (i == 0) return -1; else break; } return i; }