- java.lang.Object
-
- io.helidon.build.util.StreamUtils
-
public final class StreamUtils extends Object
Stream utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<String>toLines(InputStream in)Reads the contents of the given input stream as a list of UTF8 lines.static PrintStreamtoPrintStream(OutputStream out, boolean autoFlush)Wraps the given output stream as aPrintStreamthat uses UTF8 encoding.static StringtoString(ByteArrayOutputStream out)Reads the contents of the given output stream as a UTF8 string.static StringtoString(InputStream in)Reads the contents of the given input stream as a UTF8 string.static voidtransfer(InputStream in, OutputStream out)Transfers the contents of the given input stream to the given output stream.
-
-
-
Method Detail
-
transfer
public static void transfer(InputStream in, OutputStream out) throws IOException
Transfers the contents of the given input stream to the given output stream. This implementation uses a large shared buffer and is therefore single-threaded.- Parameters:
in- The input stream.out- The output stream.- Throws:
IOException- If an error occurs.
-
toString
public static String toString(InputStream in) throws IOException
Reads the contents of the given input stream as a UTF8 string.- Parameters:
in- The input stream.- Returns:
- The string.
- Throws:
IOException- If an error occurs.
-
toString
public static String toString(ByteArrayOutputStream out)
Reads the contents of the given output stream as a UTF8 string.- Parameters:
out- The output stream.- Returns:
- The string.
-
toPrintStream
public static PrintStream toPrintStream(OutputStream out, boolean autoFlush)
Wraps the given output stream as aPrintStreamthat uses UTF8 encoding.- Parameters:
out- The stream to wrap.autoFlush-trueIf stream should flush on each line.- Returns:
- The stream.
-
toLines
public static List<String> toLines(InputStream in) throws IOException
Reads the contents of the given input stream as a list of UTF8 lines.- Parameters:
in- The input stream.- Returns:
- The list.
- Throws:
IOException- If an error occurs.
-
-