1 package com.github.davidmoten.security;
2
3 import java.io.ByteArrayOutputStream;
4 import java.io.IOException;
5 import java.io.InputStream;
6
7 final class Bytes {
8
9 private Bytes() {
10
11 }
12
13 static byte[] from(InputStream is) {
14 try {
15 ByteArrayOutputStream bytes = new ByteArrayOutputStream();
16 int nRead;
17 byte[] buffer = new byte[1024];
18 while ((nRead = is.read(buffer)) != -1) {
19 bytes.write(buffer, 0, nRead);
20 }
21 return bytes.toByteArray();
22 } catch (IOException e) {
23 throw new RuntimeException(e);
24 }
25 }
26
27 }