Here you can find the source of getBytes(InputStream is)
public static byte[] getBytes(InputStream is)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static byte[] getBytes(InputStream is) { try {/*from w w w.j a v a2s . c om*/ ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int nRead; byte[] data = new byte[16384]; while ((nRead = is.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } buffer.flush(); System.out.println("byte: " + new String(buffer.toByteArray())); return buffer.toByteArray(); } catch (Exception e) { e.printStackTrace(); } return null; } }