be.ehealth.technicalconnector.utils

## Class ConnectorIOUtils

- java.lang.Object
- - be.ehealth.technicalconnector.utils.ConnectorIOUtils

-     public final class ConnectorIOUtils
      extends Object

  Utility class for General IO stream manipulation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `COMPRESSION_ALGO_DEFLATE` Using the compression algoritme "deflate" as specified in the RFC1951
    `static String` | `COMPRESSION_ALGO_GZIP` Using the compression algoritme "GZIP" as specified in the RFC1952

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `base64Decode(byte[] input, boolean recursive)` Helper method to decode base64 byte[] with or without recursivity.
    `static void` | `closeQuietly(Object... closeables)` Helper method to close quietly an object with the close method.
    `static void` | `closeQuietly(Object closeable)` Helper method to close quietly an object with the close method.
    `static byte[]` | `compress(byte[] input)` Compress the given byte[] by using the `COMPRESSION_ALGO_GZIP`
    `static byte[]` | `compress(byte[] input, String algo)` Compress the given byte[] by using the specified algorithm.
    `static void` | `compress(InputStream in, OutputStream out, String algo)` Compress the given `InputStream` by using the specified algo to the given `OutputStream`
    `static String` | `convertStreamToString(InputStream is)` Convert the given `InputStream` to a String
    `static File` | `createTempFile(String name)` Given a filename creates a temp file based on the java.io.tmpdir System property.
    `static File` | `createTempFile(String name, boolean create)`
    `static byte[]` | `decompress(byte[] input)` De-compress the given byte[]
    `static InputStream` | `decompress(InputStream input)` De-compress the given `InputStream` by detecting the used algorithm.
    `static void` | `decompress(InputStream in, OutputStream out, boolean noWrap)` Compress the given `InputStream` to the given `OutputStream` using the `Inflater` with or without wrap.
    `static byte[]` | `getBytes(InputStream inputStream)` Get the bytes from the given `InputStream`
    `static byte[]` | `getResourceAsByteArray(String location)` Gets content of the location as byte[]
    `static File` | `getResourceAsFile(String location)` Gets content of the location as `File`
    `static InputStream` | `getResourceAsStream(String location)` Gets the location as `InputStream`
    `static InputStream` | `getResourceAsStream(String location, boolean bootstrap)` Gets the location as `InputStream`
    `static String` | `getResourceAsString(String location)` Gets content of the location as `String`
    `static String` | `getResourceFilePath(String location)` Gets the resource as stream.
    `static String` | `getTempFileLocation(String name)` t Given a filename builds a temp file location path based on the java.io.tmpdir System property.
    `static byte[]` | `toBytes(String content, Charset charsetName)` Get the bytes from the given `String` by using the correct `Charset`
    `static String` | `toString(byte[] message, Charset charsetName)` Convert the given byte[] to a `String` by using the corrrect `Charset`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### COMPRESSION_ALGO_DEFLATE

          public static final String COMPRESSION_ALGO_DEFLATE

      Using the compression algoritme "deflate" as specified in the RFC1951
      See Also:
        Constant Field Values

    - #### COMPRESSION_ALGO_GZIP

          public static final String COMPRESSION_ALGO_GZIP

      Using the compression algoritme "GZIP" as specified in the RFC1952
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getBytes

          public static byte[] getBytes(InputStream inputStream)
                                 throws TechnicalConnectorException

      Get the bytes from the given `InputStream`

      Note: the given stream is closed.

      Throws:
        `TechnicalConnectorException`

    - #### toBytes

          public static byte[] toBytes(String content,
                                       Charset charsetName)
                                throws TechnicalConnectorException

      Get the bytes from the given `String` by using the correct `Charset`
      Throws:
        `TechnicalConnectorException`

    - #### toString

          public static String toString(byte[] message,
                                        Charset charsetName)
                                 throws TechnicalConnectorException

      Convert the given byte[] to a `String` by using the corrrect `Charset`
      Throws:
        `TechnicalConnectorException`

    - #### compress

          public static byte[] compress(byte[] input)
                                 throws TechnicalConnectorException

      Compress the given byte[] by using the `COMPRESSION_ALGO_GZIP`
      Throws:
        `TechnicalConnectorException`

    - #### compress

          public static void compress(InputStream in,
                                      OutputStream out,
                                      String algo)
                               throws TechnicalConnectorException

      Compress the given `InputStream` by using the specified algo to the given `OutputStream`

      Note:None of the streams are closed.

      Throws:
        `TechnicalConnectorException`

    - #### compress

          public static byte[] compress(byte[] input,
                                        String algo)
                                 throws TechnicalConnectorException

      Compress the given byte[] by using the specified algorithm.
      Throws:
        `TechnicalConnectorException`

    - #### decompress

          public static void decompress(InputStream in,
                                        OutputStream out,
                                        boolean noWrap)
                                 throws TechnicalConnectorException

      Compress the given `InputStream` to the given `OutputStream` using the `Inflater` with or without wrap.

      Note:None of the streams are closed.

      Throws:
        `TechnicalConnectorException`

    - #### decompress

          public static byte[] decompress(byte[] input)
                                   throws TechnicalConnectorException

      De-compress the given byte[]
      Throws:
        `TechnicalConnectorException`

    - #### decompress

          public static InputStream decompress(InputStream input)
                                        throws TechnicalConnectorException

      De-compress the given `InputStream` by detecting the used algorithm.
      Throws:
        `TechnicalConnectorException`

    - #### getResourceAsStream

          public static InputStream getResourceAsStream(String location)
                                                 throws TechnicalConnectorException

      Gets the location as `InputStream`

      Note: technical connector is bootstrapped.

      Throws:
        `TechnicalConnectorException`

    - #### getResourceAsString

          public static String getResourceAsString(String location)
                                            throws TechnicalConnectorException

      Gets content of the location as `String`

      Note: technical connector is bootstrapped.

      Throws:
        `TechnicalConnectorException`

    - #### getResourceAsByteArray

          public static byte[] getResourceAsByteArray(String location)
                                               throws TechnicalConnectorException

      Gets content of the location as byte[]

      Note: technical connector is bootstrapped.

      Throws:
        `TechnicalConnectorException`

    - #### getResourceAsStream

          public static InputStream getResourceAsStream(String location,
                                                        boolean bootstrap)
                                                 throws TechnicalConnectorException

      Gets the location as `InputStream`

      Note: technical connector can be bootstrapped.

      Throws:
        `TechnicalConnectorException`

    - #### getResourceAsFile

          public static File getResourceAsFile(String location)
                                        throws TechnicalConnectorException

      Gets content of the location as `File`

      Note: technical connector is bootstrapped.

      Throws:
        `TechnicalConnectorException`

    - #### getResourceFilePath

          public static String getResourceFilePath(String location)
                                            throws TechnicalConnectorException

      Gets the resource as stream.
      Parameters:
        `location` - the location
      Returns:
        the resource as stream
      Throws:
        `TechnicalConnectorException` - throws an TechnicalConnectorException when resoure is not found.

    - #### convertStreamToString

          public static String convertStreamToString(InputStream is)
                                              throws TechnicalConnectorException

      Convert the given `InputStream` to a String

      Note: the inputstream is closed.

      Throws:
        `TechnicalConnectorException`

    - #### closeQuietly

          public static void closeQuietly(Object closeable)

      Helper method to close quietly an object with the close method.

    - #### closeQuietly

          public static void closeQuietly(Object... closeables)

      Helper method to close quietly an object with the close method.

    - #### base64Decode

          public static byte[] base64Decode(byte[] input,
                                            boolean recursive)
                                     throws TechnicalConnectorException

      Helper method to decode base64 byte[] with or without recursivity.
      Throws:
        `TechnicalConnectorException`

    - #### createTempFile

          public static File createTempFile(String name)
                                     throws TechnicalConnectorException

      Given a filename creates a temp file based on the java.io.tmpdir System property. Unlike `File.createTempFile(String, String)` File.createTempFile} it throws a checked exception if the java.io.tmpdir System property is not defined.
      Parameters:
        `name` - the file name
      Returns:
        the created temp file
      Throws:
        `TechnicalConnectorException` - if the supplied name is empty or the java.io.tmpdir System property is not set.

    - #### getTempFileLocation

          public static String getTempFileLocation(String name)
                                            throws TechnicalConnectorException

      t Given a filename builds a temp file location path based on the java.io.tmpdir System property.
      Parameters:
        `name` - the file name
      Returns:
        the string representation of the temp file path
      Throws:
        `TechnicalConnectorException` - if the supplied name is empty or the java.io.tmpdir System property is not set.

    - #### createTempFile

          public static File createTempFile(String name,
                                            boolean create)
                                     throws TechnicalConnectorException

      Throws:
        `TechnicalConnectorException`

Connector Packaging generic 4.9.5 API
Copyright © {inceptionYear}-2026 eHealth. All Rights Reserved.