be.fgov.ehealth.etee.crypto.utils
Class Streams

java.lang.Object
  extended by be.fgov.ehealth.etee.crypto.utils.Streams

public final class Streams
extends java.lang.Object

A utility class that simplifies various operations on instances of InputStream or OutputStream.


Field Summary
static java.lang.Integer DEFAULT_BUFFER_SIZE
           
 
Method Summary
static void closeQuietly(java.io.Closeable closeable)
          Close an instance of Closeable while swallowing the possible IOException.
static void copy(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Copy the given InputStream to the given OutputStream in blocks.
static void drain(org.bouncycastle.cms.CMSTypedStream stream)
           
static java.io.InputStream fromBytes(byte[] source)
          Create an InputStream from a given byte array.
static java.io.InputStream fromOutputStream(java.io.OutputStream outputStream)
          Create a new InputStream from a given OutputStream.
static byte[] getBytes(java.io.InputStream inputStream)
          Retrieve the contents of an InputStream as a byte array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final java.lang.Integer DEFAULT_BUFFER_SIZE
Method Detail

copy

public static void copy(java.io.InputStream inputStream,
                        java.io.OutputStream outputStream)
Copy the given InputStream to the given OutputStream in blocks. After the operation the input- and output stream are closed.

Parameters:
inputStream - The source.
outputStream - The target.

getBytes

public static byte[] getBytes(java.io.InputStream inputStream)
Retrieve the contents of an InputStream as a byte array.

Parameters:
inputStream - The input stream
Returns:
The contents of the given input stream as a byte array.

fromBytes

public static java.io.InputStream fromBytes(byte[] source)
Create an InputStream from a given byte array.

Parameters:
source - The source from which to make an InputStream
Returns:
An InputStream

fromOutputStream

public static java.io.InputStream fromOutputStream(java.io.OutputStream outputStream)
Create a new InputStream from a given OutputStream. (Pipe the output stream)

Parameters:
outputStream - The source from which to make an InputStream
Returns:
An InputStream

closeQuietly

public static void closeQuietly(java.io.Closeable closeable)
Close an instance of Closeable while swallowing the possible IOException.

Parameters:
closeable - The instance that needs to be closed.

drain

public static void drain(org.bouncycastle.cms.CMSTypedStream stream)


Copyright © 2019 eHealth. All Rights Reserved.