Here you can find the source of readAll(InputStream s)
static public byte[] readAll(InputStream s)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { static public byte[] readAll(InputStream s) { byte[] temp = new byte[1024]; ByteArrayOutputStream os = new ByteArrayOutputStream(); try {/*from ww w . j a va 2 s. c om*/ while (true) { int read = s.read(temp, 0, temp.length); if (read <= 0) break; os.write(temp, 0, read); } } catch (IOException e) { e.printStackTrace(); } return os.toByteArray(); } }