Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/mumla.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/lublin/mumla/util/InputStreamUtils.java')
-rw-r--r--app/src/main/java/se/lublin/mumla/util/InputStreamUtils.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/src/main/java/se/lublin/mumla/util/InputStreamUtils.java b/app/src/main/java/se/lublin/mumla/util/InputStreamUtils.java
new file mode 100644
index 0000000..0030984
--- /dev/null
+++ b/app/src/main/java/se/lublin/mumla/util/InputStreamUtils.java
@@ -0,0 +1,20 @@
+package se.lublin.mumla.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+public class InputStreamUtils {
+ public static byte[] getBytes(InputStream stream) throws IOException {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ byte[] tempBuffer = new byte[1024];
+
+ int length;
+ while((length = stream.read(tempBuffer)) != -1){
+ buffer.write(tempBuffer, 0, length);
+ }
+
+ return buffer.toByteArray();
+ }
+}