Class IoUtil

java.lang.Object
org.camunda.commons.utils.IoUtil
Direct Known Subclasses:
SpinIoUtil

public class IoUtil extends Object
Author:
Sebastian Menski
  • Field Details

    • ENCODING_CHARSET

      public static final Charset ENCODING_CHARSET
  • Constructor Details

    • IoUtil

      public IoUtil()
  • Method Details

    • inputStreamAsString

      public static String inputStreamAsString(InputStream inputStream)
      Returns the input stream as String.
      Parameters:
      inputStream - the input stream
      Returns:
      the input stream as String.
    • inputStreamAsByteArray

      public static byte[] inputStreamAsByteArray(InputStream inputStream)
      Returns the input stream as byte[].
      Parameters:
      inputStream - the input stream
      Returns:
      the input stream as byte[].
    • readerAsString

      public static String readerAsString(Reader reader)
      Returns the Reader content as String.
      Parameters:
      reader - the Reader
      Returns:
      the Reader content as String
    • stringAsInputStream

      public static InputStream stringAsInputStream(String string)
      Returns the String as InputStream.
      Parameters:
      string - the String to convert
      Returns:
      the InputStream containing the String
    • closeSilently

      public static void closeSilently(Closeable closeable)
      Close a closable ignoring any IO exception.
      Parameters:
      closeable - the closable to close
    • fileAsString

      public static String fileAsString(String filename)
      Returns the content of a file with specified filename
      Parameters:
      filename - name of the file to load
      Returns:
      Content of the file as String
    • fileAsString

      public static String fileAsString(File file)
      Returns the content of a File.
      Parameters:
      file - the file to load
      Returns:
      Content of the file as String
    • fileAsByteArray

      public static byte[] fileAsByteArray(File file)
      Returns the content of a File.
      Parameters:
      file - the file to load
      Returns:
      Content of the file as String
    • fileAsStream

      public static InputStream fileAsStream(String filename)
      Returns the input stream of a file with specified filename
      Parameters:
      filename - the name of a File to load
      Returns:
      the file content as input stream
      Throws:
      IoUtilException - if the file cannot be loaded
    • fileAsStream

      public static InputStream fileAsStream(File file)
      Returns the input stream of a file.
      Parameters:
      file - the File to load
      Returns:
      the file content as input stream
      Throws:
      IoUtilException - if the file cannot be loaded
    • getClasspathFile

      public static File getClasspathFile(String filename)
      Returns the File for a filename.
      Parameters:
      filename - the filename to load
      Returns:
      the file object
    • getClasspathFile

      public static File getClasspathFile(String filename, ClassLoader classLoader)
      Returns the File for a filename.
      Parameters:
      filename - the filename to load
      classLoader - the classLoader to load file with, if null falls back to TCCL and then this class's classloader
      Returns:
      the file object
      Throws:
      IoUtilException - if the file cannot be loaded