Here you can find the source of getBytes(InputStream fis)
public static byte[] getBytes(InputStream fis)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] getBytes(InputStream fis) { byte[] buffer = null; try {// w ww . j a va 2s. c o m ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); byte[] b = new byte[1000]; int n; while ((n = fis.read(b)) != -1) { bos.write(b, 0, n); } fis.close(); bos.close(); buffer = bos.toByteArray(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return buffer; } }