Package com.castlabs.utils
Class IOUtils
java.lang.Object
com.castlabs.utils.IOUtils
Utility functions for IO operations
- Since:
- 2.0.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcloseQuietly(com.google.android.exoplayer2.upstream.DataSource closeable) Quietly close the given DataSource and ignore any IO exceptions.static voidcloseQuietly(Closeable closeable) Quietly close the given closable and ignore any IO exceptions.static voidcopy(InputStream input, OutputStream output) Copy the content from the input to the output stream and closes both the input and the output streamstatic voidcopy(InputStream input, Writer writer) Copy the input stream content as UTF-8 chars to the writerstatic voidCopy the content from teh given reader to the given writer and closes reader and writerstatic byte[]toByteArray(InputStream content) Read and return the content of the given stream as byte[]static StringtoString(InputStream content) Gets the contents of an InputStream as a String assuming UTF8 encoding
- 
Constructor Details- 
IOUtilspublic IOUtils()
 
- 
- 
Method Details- 
toStringGets the contents of an InputStream as a String assuming UTF8 encoding- Parameters:
- content- the input
- Returns:
- content of the given input stream as String
- Throws:
- IOException- in case of any errors
 
- 
toByteArrayRead and return the content of the given stream as byte[]- Parameters:
- content- the content
- Returns:
- byte array of the content of the stream
- Throws:
- IOException- in case of any errors
 
- 
closeQuietlyQuietly close the given closable and ignore any IO exceptions. Null input will be ignored.- Parameters:
- closeable- the closable. If null the method will just return.
 
- 
closeQuietlypublic static void closeQuietly(@Nullable com.google.android.exoplayer2.upstream.DataSource closeable) Quietly close the given DataSource and ignore any IO exceptions. Null input will be ignored.- Parameters:
- closeable- the closable. If null the method will just return.
 
- 
copyCopy the input stream content as UTF-8 chars to the writer- Parameters:
- input- input stream
- writer- output writer
- Throws:
- IOException- in case of an error
 
- 
copyCopy the content from teh given reader to the given writer and closes reader and writer- Parameters:
- reader- the reader
- writer- the writer
- Throws:
- IOException- in case of an error
 
- 
copyCopy the content from the input to the output stream and closes both the input and the output stream- Parameters:
- input- the input stream
- output- the output stream
- Throws:
- IOException- in case of an IO error while reading or writing the streams
 
 
-