Package org.camunda.commons.utils
Class IoUtil
- java.lang.Object
-
- org.camunda.commons.utils.IoUtil
-
public class IoUtil extends java.lang.Object- Author:
- Sebastian Menski
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetENCODING_CHARSET
-
Constructor Summary
Constructors Constructor Description IoUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseSilently(java.io.Closeable closeable)Close a closable ignoring any IO exception.static byte[]fileAsByteArray(java.io.File file)Returns the content of a File.static java.io.InputStreamfileAsStream(java.io.File file)Returns the input stream of a file.static java.io.InputStreamfileAsStream(java.lang.String filename)Returns the input stream of a file with specified filenamestatic java.lang.StringfileAsString(java.io.File file)Returns the content of a File.static java.lang.StringfileAsString(java.lang.String filename)Returns the content of a file with specified filenamestatic java.io.FilegetClasspathFile(java.lang.String filename)Returns the File for a filename.static java.io.FilegetClasspathFile(java.lang.String filename, java.lang.ClassLoader classLoader)Returns the File for a filename.static byte[]inputStreamAsByteArray(java.io.InputStream inputStream)Returns the input stream as byte[].static java.lang.StringinputStreamAsString(java.io.InputStream inputStream)Returns the input stream as String.static java.lang.StringreaderAsString(java.io.Reader reader)Returns the Reader content as String.static java.io.InputStreamstringAsInputStream(java.lang.String string)Returns the String as InputStream.
-
-
-
Method Detail
-
inputStreamAsString
public static java.lang.String inputStreamAsString(java.io.InputStream inputStream)
Returns the input stream as String.- Parameters:
inputStream- the input stream- Returns:
- the input stream as String.
-
inputStreamAsByteArray
public static byte[] inputStreamAsByteArray(java.io.InputStream inputStream)
Returns the input stream as byte[].- Parameters:
inputStream- the input stream- Returns:
- the input stream as byte[].
-
readerAsString
public static java.lang.String readerAsString(java.io.Reader reader)
Returns the Reader content as String.- Parameters:
reader- the Reader- Returns:
- the Reader content as String
-
stringAsInputStream
public static java.io.InputStream stringAsInputStream(java.lang.String string)
Returns the String as InputStream.- Parameters:
string- the String to convert- Returns:
- the InputStream containing the String
-
closeSilently
public static void closeSilently(java.io.Closeable closeable)
Close a closable ignoring any IO exception.- Parameters:
closeable- the closable to close
-
fileAsString
public static java.lang.String fileAsString(java.lang.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 java.lang.String fileAsString(java.io.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(java.io.File file)
Returns the content of a File.- Parameters:
file- the file to load- Returns:
- Content of the file as String
-
fileAsStream
public static java.io.InputStream fileAsStream(java.lang.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 java.io.InputStream fileAsStream(java.io.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 java.io.File getClasspathFile(java.lang.String filename)
Returns the File for a filename.- Parameters:
filename- the filename to load- Returns:
- the file object
-
getClasspathFile
public static java.io.File getClasspathFile(java.lang.String filename, java.lang.ClassLoader classLoader)Returns the File for a filename.- Parameters:
filename- the filename to loadclassLoader- 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
-
-