protected DataInputStream getDataInputStream()

in commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpRandomAccessContent.java [59:101]


    protected DataInputStream getDataInputStream() throws IOException {
        if (dis != null) {
            return dis;
        }

        // FtpClient client = fileSystem.getClient();
        mis = fileObject.getInputStream(filePointer);
        dis = new DataInputStream(new FilterInputStream(mis) {
            @Override
            public void close() throws IOException {
                FtpRandomAccessContent.this.close();
            }

            @Override
            public int read() throws IOException {
                final int ret = super.read();
                if (ret > -1) {
                    filePointer++;
                }
                return ret;
            }

            @Override
            public int read(final byte[] b) throws IOException {
                final int ret = super.read(b);
                if (ret > -1) {
                    filePointer += ret;
                }
                return ret;
            }

            @Override
            public int read(final byte[] b, final int off, final int len) throws IOException {
                final int ret = super.read(b, off, len);
                if (ret > -1) {
                    filePointer += ret;
                }
                return ret;
            }
        });

        return dis;
    }