goja-core/src/main/java/goja/core/kits/stream/StreamUtil.java
public static int copy(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[ioBufferSize];
        int count = 0;
        int read;
        while (true) {
            read = input.read(buffer, 0, ioBufferSize);
            if (read == -1) {
                break;
            }
            output.write(buffer, 0, read);
            count += read;
        }
        return count;
    }
public static int copy(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[ioBufferSize];
        int count = 0;
        int read;
        while (true) {
            read = input.read(buffer, 0, ioBufferSize);
            if (read == -1) {
                break;
            }
            output.write(buffer, 0, read);
            count += read;
        }
        return count;
    }
Copies input stream to output stream using buffer. Streams don't have
to be wrapped to buffered, since copying is already optimized.