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

org.bouncycastle.crypto.UpdateOutputStream Maven / Gradle / Ivy

Go to download

The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.

There is a newer version: 2.0.0
Show newest version
package org.bouncycastle.crypto;

import java.io.IOException;
import java.io.OutputStream;

/**
 * An extension of output stream that provides update methods which allow
 * for data to feed into the stream without the need to handle checked exceptions.
 */
public abstract class UpdateOutputStream
    extends OutputStream
{
    /**
     * Update the stream with the passed in byte.
     *
     * @param b the data to be written to the stream.
     */
    public final void update(byte b)
    {
        try
        {
            write(b);
        }
        catch (IOException e)
        {
            if (e.getCause() != null)
            {
                throw new UpdateException(e.getClass().getName() + ": " + e.getMessage(), e.getCause());
            }
            else
            {
                throw new UpdateException("Exception processing data: " + e.getMessage(), e);
            }
        }
    }

    /**
     * Update the stream with the passed in buffer.
     *
     * @param buffer the data to be written to the stream.
     */
    public final void update(byte[] buffer)
    {
        update(buffer, 0, buffer.length);
    }

    /**
     * Update the stream with a section of the passed in buffer.
     *
     * @param buffer the buffer holding the data to be written.
     * @param off the offset into buffer at which the data starts.
     * @param len the length of the data to be written.
     */
    public final void update(byte[] buffer, int off, int len)
    {
        try
        {
            write(buffer, off, len);
        }
        catch (IOException e)
        {
            if (e.getCause() != null)
            {
                throw new UpdateException(e.getClass().getName() + ": " + e.getMessage(), e.getCause());
            }
            else
            {
                throw new UpdateException("Exception processing data: " + e.getMessage(), e);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy