org.camunda.commons.utils
Class IoUtil

java.lang.Object
  extended by org.camunda.commons.utils.IoUtil

public class IoUtil
extends Object

Author:
Sebastian Menski

Field Summary
static Charset ENCODING_CHARSET
           
 
Constructor Summary
IoUtil()
           
 
Method Summary
static void closeSilently(Closeable closeable)
          Close a closable ignoring any IO exception.
static InputStream fileAsStream(File file)
          Returns the input stream of a file.
static InputStream fileAsStream(String filename)
          Returns the input stream of a file with specified filename
static String fileAsString(File file)
          Returns the content of a File.
static String fileAsString(String filename)
          Returns the content of a file with specified filename
static File getClasspathFile(String filename)
          Returns the File for a filename.
static File getClasspathFile(String filename, ClassLoader classLoader)
          Returns the File for a filename.
static String inputStreamAsString(InputStream inputStream)
          Returns the input stream as String.
static String readerAsString(Reader reader)
          Returns the Reader content as String.
static InputStream stringAsInputStream(String string)
          Returns the String as InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODING_CHARSET

public static final Charset ENCODING_CHARSET
Constructor Detail

IoUtil

public IoUtil()
Method Detail

inputStreamAsString

public static String inputStreamAsString(InputStream inputStream)
Returns the input stream as String.

Parameters:
inputStream - the input stream

readerAsString

public static String readerAsString(Reader reader)
Returns the Reader content as String.

Parameters:
reader - the Reader

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

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


Copyright © 2015 camunda services GmbH. All rights reserved.