Remove dependencies to Argeo Commons IO
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / StreamUtils.java
index 30404f1e4edc195b9270488b1b0ed41eb7056187..5e4e636fc45073f3615e5b9d6ce459bbc3c8ed3c 100644 (file)
@@ -1,6 +1,7 @@
 package org.argeo.util;
 
 import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -44,6 +45,13 @@ public class StreamUtils {
                return count;
        }
 
+       public static byte[] toByteArray(InputStream in) throws IOException {
+               try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+                       copy(in, out);
+                       return out.toByteArray();
+               }
+       }
+
        public static void closeQuietly(InputStream in) {
                if (in != null)
                        try {