Package org.camunda.commons.utils
Class IoUtil
java.lang.Object
org.camunda.commons.utils.IoUtil
- Direct Known Subclasses:
SpinIoUtil
- Author:
- Sebastian Menski
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeSilently
(Closeable closeable) Close a closable ignoring any IO exception.static byte[]
fileAsByteArray
(File file) Returns the content of a File.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 filenamestatic String
fileAsString
(File file) Returns the content of a File.static String
fileAsString
(String filename) Returns the content of a file with specified filenamestatic File
getClasspathFile
(String filename) Returns the File for a filename.static File
getClasspathFile
(String filename, ClassLoader classLoader) Returns the File for a filename.static byte[]
inputStreamAsByteArray
(InputStream inputStream) Returns the input stream as byte[].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.
-
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
-