nilsimsa icon indicating copy to clipboard operation
nilsimsa copied to clipboard

Add update() support for partial data in input buffer

Open rustyx opened this issue 5 years ago • 0 comments

This makes it easier to update() from a data buffer, i.e. when reading from a stream.

        Nilsimsa nilsimsa = new Nilsimsa();
        byte buf[] = new byte[4096];
        for (int len = maxlen; len > 0;) {
            int bytesRead = content.read(buf, 0, Math.min(buf.length, len));
            if (bytesRead < 0)
                break;
            nilsimsa.update(buf, 0, bytesRead); // <=== LOOK!
            len -= bytesRead;
        }

rustyx avatar Sep 17 '18 09:09 rustyx