All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.util.io.LimitedBuffer Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.

There is a newer version: 1.79
Show newest version
package org.bouncycastle.util.io;

import java.io.OutputStream;

public class LimitedBuffer extends OutputStream
{
    private final byte[] buf;
    private int count;

    public LimitedBuffer(int limit)
    {
        buf = new byte[limit];
        count = 0;
    }

    public int copyTo(byte[] b, int off)
    {
        System.arraycopy(buf, 0, b, off, count);
        return count;
    }

    public int limit()
    {
        return buf.length;
    }

    public void reset()
    {
        count = 0;
    }

    public int size()
    {
        return count;
    }

    public void write(int b)
    {
        buf[count++] = (byte)b;
    }

    public void write(byte[] b)
    {
        System.arraycopy(b, 0, buf, count, b.length);
        count += b.length;
    }

    public void write(byte b[], int off, int len)
    {
        System.arraycopy(b, off, buf, count, len);
        count += len;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy