summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-10-05 12:23:27 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2017-10-05 12:25:35 +0200
commit113315ed2cc6958bb9241f616f14c7f9f7c7c70e (patch)
tree7c57f42ca47b7ed22b3dad6203acd0e4072b499e /vespajlib
parent81b9d23e0e85e73626ff6edea446741bb263b465 (diff)
Add convenience methods
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/io/IOUtils.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/io/IOUtils.java b/vespajlib/src/main/java/com/yahoo/io/IOUtils.java
index a5e16fc89ea..2572842b213 100644
--- a/vespajlib/src/main/java/com/yahoo/io/IOUtils.java
+++ b/vespajlib/src/main/java/com/yahoo/io/IOUtils.java
@@ -14,9 +14,10 @@ import java.nio.ByteBuffer;
* <p>Some static io convenience methods.</p>
*
* @author bratseth
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
+ * @author Bjorn Borud
*/
public abstract class IOUtils {
+
static private final Charset utf8Charset = Charset.forName("utf-8");
/** Closes a writer, or does nothing if the writer is null */
@@ -410,6 +411,11 @@ public abstract class IOUtils {
return ret.toString();
}
+ /** Read an input stream completely into a string */
+ public static String readAll(InputStream stream, Charset charset) throws IOException {
+ return readAll(new InputStreamReader(stream, charset));
+ }
+
/** Convenience method for closing a list of readers. Does nothing if the given reader list is null. */
public static void closeAll(List<Reader> readers) {
if (readers==null) return;