diff options
Diffstat (limited to 'netx/net/sourceforge/jnlp/util/StreamUtils.java')
-rw-r--r-- | netx/net/sourceforge/jnlp/util/StreamUtils.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/netx/net/sourceforge/jnlp/util/StreamUtils.java b/netx/net/sourceforge/jnlp/util/StreamUtils.java index 3a179d5..7dd7a92 100644 --- a/netx/net/sourceforge/jnlp/util/StreamUtils.java +++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java @@ -37,9 +37,11 @@ exception statement from your version. package net.sourceforge.jnlp.util; +import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; public class StreamUtils { @@ -71,4 +73,21 @@ public class StreamUtils { } } } + + + public static String readStreamAsString(InputStream stream) throws IOException { + InputStreamReader is = new InputStreamReader(stream); + StringBuilder sb = new StringBuilder(); + BufferedReader br = new BufferedReader(is); + while (true) { + String read = br.readLine(); + if (read == null) { + break; + } + sb.append(read); + + } + + return sb.toString(); + } } |