Package info.freelibrary.util
Class IOUtils
- java.lang.Object
-
- info.freelibrary.util.IOUtils
-
public final class IOUtils extends Object
Utilities for working with IO streams.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
closeQuietly(InputStream aInputStream)
Closes an input stream, catching and logging any exceptions.static void
closeQuietly(OutputStream aOutputStream)
Closes an output stream, catching and logging any exceptions.static void
closeQuietly(Reader aReader)
Closes a reader, catching and logging any exceptions.static void
closeQuietly(Writer aWriter)
Closes a writer, catching and logging any exceptions.static void
closeQuietly(JarFile aJarFile)
Closes aJarFile
, catching and logging any exceptions.static void
closeQuietly(ImageInputStream aImageInputStream)
Closes an image input stream, catching and logging any exceptionsstatic void
closeQuietly(ImageOutputStream aImageOutputStream)
Closes an image output stream, catching and logging any exceptions.static void
copyStream(File aFile, OutputStream aOutStream)
Writes a file to an output stream.static void
copyStream(InputStream aInStream, OutputStream aOutStream)
Writes from an input stream to an output stream; you're responsible for closing theInputStream
andOutputStream
.static byte[]
readBytes(InputStream aInputStream)
Reads an InputStream into a byte array.
-
-
-
Method Detail
-
closeQuietly
public static void closeQuietly(Reader aReader)
Closes a reader, catching and logging any exceptions.- Parameters:
aReader
- A supplied reader to close
-
closeQuietly
public static void closeQuietly(Writer aWriter)
Closes a writer, catching and logging any exceptions.- Parameters:
aWriter
- A supplied writer to close
-
closeQuietly
public static void closeQuietly(InputStream aInputStream)
Closes an input stream, catching and logging any exceptions.- Parameters:
aInputStream
- A supplied input stream to close
-
closeQuietly
public static void closeQuietly(ImageInputStream aImageInputStream)
Closes an image input stream, catching and logging any exceptions- Parameters:
aImageInputStream
- A supplied image input stream to close
-
closeQuietly
public static void closeQuietly(ImageOutputStream aImageOutputStream)
Closes an image output stream, catching and logging any exceptions.- Parameters:
aImageOutputStream
- A supplied image output stream to close
-
closeQuietly
public static void closeQuietly(OutputStream aOutputStream)
Closes an output stream, catching and logging any exceptions.- Parameters:
aOutputStream
- A supplied output stream to close
-
closeQuietly
public static void closeQuietly(JarFile aJarFile)
Closes aJarFile
, catching and logging any exceptions.- Parameters:
aJarFile
- A suppliedJarFile
to close
-
copyStream
public static void copyStream(InputStream aInStream, OutputStream aOutStream) throws IOException
Writes from an input stream to an output stream; you're responsible for closing theInputStream
andOutputStream
.- Parameters:
aInStream
- The stream from which to readaOutStream
- The stream from which to write- Throws:
IOException
- If there is trouble reading or writing
-
copyStream
public static void copyStream(File aFile, OutputStream aOutStream) throws IOException
Writes a file to an output stream. You're responsible for closing theOutputStream
; the input stream is closed for you since just aFile
was passed in.- Parameters:
aFile
- A file from which to readaOutStream
- An output stream to which to write- Throws:
IOException
- If there is a problem reading or writing
-
readBytes
public static byte[] readBytes(InputStream aInputStream) throws IOException
Reads an InputStream into a byte array.- Parameters:
aInputStream
- The input stream from which to read- Returns:
- The array of bytes
- Throws:
IOException
- If there is trouble reading from the input stream
-
-