public RamFileRandomAccessContent()

in commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java [79:126]


    public RamFileRandomAccessContent(final RamFileObject file, final RandomAccessMode mode) {
        Objects.requireNonNull(file, "file");
        Objects.requireNonNull(mode, "mode");
        this.buf = file.getData().getContent();
        this.file = file;

        rafis = new InputStream() {
            @Override
            public int available() throws IOException {
                return getLeftBytes();
            }

            @Override
            public void close() throws IOException {
            }

            @Override
            public int read() throws IOException {
                try {
                    return readByte() & BYTE_VALUE_MASK;
                } catch (final EOFException e) {
                    return -1;
                }
            }

            @Override
            public int read(final byte[] b) throws IOException {
                return read(b, 0, b.length);
            }

            @Override
            public int read(final byte[] b, final int off, final int len) throws IOException {
                int retLen = -1;
                final int left = getLeftBytes();
                if (left > 0) {
                    retLen = Math.min(len, left);
                    RamFileRandomAccessContent.this.readFully(b, off, retLen);
                }
                return retLen;
            }

            @Override
            public long skip(final long n) throws IOException {
                seek(getFilePointer() + n);
                return n;
            }
        };
    }