Android examples for File Input Output:Byte Array Convert
extract InputStream to byte array
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] extract(InputStream inputStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int read = 0; while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) { baos.write(buffer, 0, read); }//from w w w . j a va2 s.c om baos.flush(); return baos.toByteArray(); } }