Android examples for File Input Output:InputStream
read InputStream and return byte array
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static byte[] readStream(InputStream inStream) throws Exception { byte[] buffer = new byte[1024]; int len = -1; ByteArrayOutputStream outStream = new ByteArrayOutputStream(); while ((len = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, len); }/*from ww w .j av a2s. c o m*/ byte[] data = outStream.toByteArray(); outStream.close(); inStream.close(); return data; } }