Here you can find the source of readFile(InputStream ios)
public static byte[] readFile(InputStream ios) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] readFile(File file) throws IOException { FileInputStream fis = new FileInputStream(file); byte[] bs = readFile(fis); return bs; }/*w w w . j av a 2s . c om*/ public static byte[] readFile(InputStream ios) throws IOException { ByteArrayOutputStream ous = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int read = 0; while ((read = ios.read(buffer)) != -1) { ous.write(buffer, 0, read); } byte[] bs = ous.toByteArray(); ous.close(); ios.close(); return bs; } }