Android examples for File Input Output:Byte Array Convert
read Input Stream to byte array
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static byte[] readInputStream(InputStream in) throws Exception { int len = 0; byte buf[] = new byte[1024]; ByteArrayOutputStream out = new ByteArrayOutputStream(); while ((len = in.read(buf)) != -1) { out.write(buf, 0, len);//from w w w . java 2 s . c o m } out.close(); return out.toByteArray(); } }