Android examples for java.lang:Array Element
read InputStream To End As Array
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] readToEndAsArray(InputStream input) throws IOException { DataInputStream dis = new DataInputStream(input); byte[] stuff = new byte[1024]; ByteArrayOutputStream buff = new ByteArrayOutputStream(); int read = 0; while ((read = dis.read(stuff)) != -1) { buff.write(stuff, 0, read);// w ww .j a va 2 s . c om } dis.close(); return buff.toByteArray(); } }