(InputStream stream)
| 9 | public class ByteStreamReader { |
| 10 | |
| 11 | public static byte[] read(InputStream stream) throws IOException { |
| 12 | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| 13 | |
| 14 | int c = 0; |
| 15 | |
| 16 | while (c > -1) { |
| 17 | byte[] buf = new byte[4096]; |
| 18 | c = stream.read(buf); |
| 19 | |
| 20 | if (c > 0) |
| 21 | output.write(buf, 0, c); |
| 22 | } |
| 23 | |
| 24 | return output.toByteArray(); |
| 25 | } |
| 26 | |
| 27 | public static byte[] read(InputStream stream, int offset, int count) throws IOException { |
| 28 | ByteArrayOutputStream output = new ByteArrayOutputStream(); |