Package org.openl.util
Class IOUtils
java.lang.Object
org.openl.util.IOUtils
A set of utils to work with general IO streams.
- Author:
- Yury Molchan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseQuietly(AutoCloseable closeable) Unconditionally close aAutoCloseable.static voidcopy(InputStream input, OutputStream output, byte[] buffer) Copy bytes fromInputStreamto anOutputStream.static voidcopyAndClose(InputStream input, OutputStream output) Copy bytes fromInputStreamto anOutputStreamand close them after.static InputStreamtoInputStream(CharSequence input) Convert the specified CharSequence to an input stream, encoded as bytes using UTF-8 character encoding.
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
closeQuietly
Unconditionally close aAutoCloseable. Equivalent toAutoCloseable.close(), except any exceptions will be ignored.- Parameters:
closeable- the object to close, may be null or already closed
-
copyAndClose
Copy bytes fromInputStreamto anOutputStreamand close them after.- Parameters:
input- theInputStreamto read fromoutput- theOutputStreamto write to- Throws:
NullPointerException- if the input or output is nullIOException- if an I/O error occurs
-
copy
Copy bytes fromInputStreamto anOutputStream. This method uses the provided buffer, so there is no need to use aBufferedInputStream.- Parameters:
input- theInputStreamto read fromoutput- theOutputStreamto write tobuffer- the buffer to use for the copy- Throws:
NullPointerException- if the input or output is nullIOException- if an I/O error occurs
-
toInputStream
Convert the specified CharSequence to an input stream, encoded as bytes using UTF-8 character encoding.- Parameters:
input- the CharSequence to convert- Returns:
- an input stream
-