public int read()

in src/main/java/org/apache/sling/scripting/javascript/io/EspReader.java [289:311]


    public int read(char[] cbuf, int off, int len) throws java.io.IOException {
        ensureOpen();

        // Check lines (taken from InputStreamReader ;-)
        if ((off < 0) || (off > cbuf.length) || (len < 0)
            || ((off + len) > cbuf.length) || ((off + len) < 0)) {
            throw new IndexOutOfBoundsException();
        } else if (len == 0) {
            return 0;
        }

        int i;
        for (i = 0; i < len; i++, off++) {
            int c = doRead();
            if (c < 0) {
                break;
            }
            cbuf[off] = (char) c;
        }

        // return EOF (-1) if none have been read, else return the number read
        return (i == 0) ? -1 : i;
    }