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