Package de.julielab.java.utilities
Class IOStreamUtilities
- java.lang.Object
-
- de.julielab.java.utilities.IOStreamUtilities
-
public class IOStreamUtilities extends Object
-
-
Constructor Summary
Constructors Constructor Description IOStreamUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<String>getLinesFromInputStream(InputStream is)Interprets is as a stream of UTF-8 encoded lines and returns all lines.static BufferedReadergetReaderFromInputStream(InputStream is)Returns a buffered reader with UTF-8 encoding from the given input stream.static StringgetStringFromInputStream(InputStream is)Converts an InputStream into a single String using a ByteArrayOutputStream as a buffer.
-
-
-
Method Detail
-
getReaderFromInputStream
public static BufferedReader getReaderFromInputStream(InputStream is)
Returns a buffered reader with UTF-8 encoding from the given input stream.- Parameters:
is- The input stream to get an UTF-8 reader from.- Returns:
- A UTF-8 encoding reader.
-
getLinesFromInputStream
public static List<String> getLinesFromInputStream(InputStream is) throws IOException
Interprets is as a stream of UTF-8 encoded lines and returns all lines.- Parameters:
is- The input stream.- Returns:
- All UTF-8 encoded lines from the input stream.
- Throws:
IOException- If reading fails.
-
getStringFromInputStream
public static String getStringFromInputStream(InputStream is) throws IOException
Converts an InputStream into a single String using a ByteArrayOutputStream as a buffer.
Inspired by https://stackoverflow.com/a/48775964/1314955.
- Parameters:
is- The InputStream to convert into a String.- Returns:
- The string contents of is.
- Throws:
IOException- If reading fails.
-
-