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

InputStreamUtils.java « util « mumla « lublin « se « java « main « src « app - gitlab.com/quite/mumla.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84ee9b269377e4812a76394537f9c1a50b1254df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package se.lublin.mumla.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class InputStreamUtils {
    public static byte[] getBytes(InputStream stream) throws IOException {
        ByteArrayOutputStream outBuf = new ByteArrayOutputStream();
        try {
            byte[] buf = new byte[1024];
            int len;
            while ((len = stream.read(buf)) != -1) {
                outBuf.write(buf, 0, len);
            }
        } finally {
            outBuf.close();
        }
        return outBuf.toByteArray();
    }
}