Package codes.thischwa.jii.util
Class IOUtil
- java.lang.Object
-
- codes.thischwa.jii.util.IOUtil
-
public class IOUtil extends Object
Static helper object for IO related issues.- Author:
- Thilo Schwarz
-
-
Field Summary
Fields Modifier and Type Field Description static String
defaultEncoding
Default character encoding.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
closeQuietly(Closeable closeable)
Unconditionally close the desiredCloseable
.static void
closeQuietly(ImageReader iReader)
Unconditionally close the desiredImageReader
.static void
closeQuietly(ImageInputStream ii)
Unconditionally close the desiredImageInputStream
.static List<String>
parseLineByLine(InputStream in)
Parse an InputStream line-by-line.static String
toString(InputStream in)
Get the contents of anInputStream
as a String using the default character encodingdefaultEncoding
.static String
toString(InputStream in, String encoding)
Get the contents of anInputStream
as a String using the specified character encoding.
-
-
-
Field Detail
-
defaultEncoding
public static final String defaultEncoding
Default character encoding.- See Also:
- Constant Field Values
-
-
Method Detail
-
closeQuietly
public static void closeQuietly(Closeable closeable)
Unconditionally close the desiredCloseable
.- Parameters:
closeable
- Can benull
.
-
closeQuietly
public static void closeQuietly(ImageReader iReader)
Unconditionally close the desiredImageReader
.- Parameters:
iReader
- Can benull
.
-
closeQuietly
public static void closeQuietly(ImageInputStream ii)
Unconditionally close the desiredImageInputStream
.- Parameters:
ii
- Can benull
.
-
toString
public static String toString(InputStream in) throws IOException
Get the contents of anInputStream
as a String using the default character encodingdefaultEncoding
.- Parameters:
in
- TheInputStream
to read from.- Returns:
- The requested String.
- Throws:
IOException
- If an I/O error occurs
-
toString
public static String toString(InputStream in, String encoding) throws IOException
Get the contents of anInputStream
as a String using the specified character encoding.- Parameters:
in
- TheInputStream
to read from.encoding
- The character encoding to use.- Returns:
- The requested String.
- Throws:
IOException
- If an I/O error occurs
-
parseLineByLine
public static List<String> parseLineByLine(InputStream in) throws IOException
Parse an InputStream line-by-line.- Parameters:
in
-InputStream
of the output.- Returns:
- List of lines.
- Throws:
IOException
- If an I/O error occurs.
-
-