goja-core/src/main/java/goja/core/kits/stream/StreamUtil.java
public static int copy(InputStream input, OutputStream output, int byteCount) throws IOException {
        byte buffer[] = new byte[ioBufferSize];
        int count = 0;
        int read;
        while (byteCount > 0) {
            if (byteCount < ioBufferSize) {
                read = input.read(buffer, 0, byteCount);
            } else {
                read = input.read(buffer, 0, ioBufferSize);
            }
            if (read == -1) {
                break;
            }
            byteCount -= read;
            count += read;
            output.write(buffer, 0, read);
        }
        return count;
    }
public static int copy(InputStream input, OutputStream output, int byteCount) throws IOException {
        byte buffer[] = new byte[ioBufferSize];
        int count = 0;
        int read;
        while (byteCount > 0) {
            if (byteCount < ioBufferSize) {
                read = input.read(buffer, 0, byteCount);
            } else {
                read = input.read(buffer, 0, ioBufferSize);
            }
            if (read == -1) {
                break;
            }
            byteCount -= read;
            count += read;
            output.write(buffer, 0, read);
        }
        return count;
    }
public static int copy ( InputStream input , OutputStream output , int byteCount ) throws IOException { byte buffer [ ] = new byte [ ioBufferSize ] ; int count = 0 ; int read ; while ( byteCount > 0 ) { if ( byteCount < ioBufferSize ) { read = input . read ( buffer , 0 , byteCount ) ; } else { read = input . read ( buffer , 0 , ioBufferSize ) ; } if ( read == - 1 ) { break ; } byteCount -= read ; count += read ; output . write ( buffer , 0 , read ) ; } return count ; }
Copies specified number of bytes from input stream to output stream using buffer.
Copies specified number of bytes from input stream to output stream using buffer .