Android examples for java.io:InputStream
read Input Stream Fully
import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main{ public static byte[] readInputStreamFully(InputStream is) { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buffer = new byte[32768]; int count; try {/*from w w w . j av a 2 s .c o m*/ while ((count = is.read(buffer)) != -1) { os.write(buffer, 0, count); } is.close(); } catch (IOException e) { throw new RuntimeException(e); } return os.toByteArray(); } }