class LimitedInputStream extends InputStream {

    @Override
    public void mark(int readlimit) {
        in.mark(readlimit);
        limit -= bytesRead;
        bytesRead = 0;
    }

    public  LimitedInputStream(final InputStream in, final long limit);

}