Here you can find the source of loadIntoMemory(InputStream is)
public static byte[] loadIntoMemory(InputStream is) throws IOException
//package com.java2s; /* // ww w .j a va 2s .c om GeoGebra - Dynamic Mathematics for Everyone http://www.geogebra.org This file is part of GeoGebra. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /** * Writes all contents of the given InputStream to a byte array. */ public static byte[] loadIntoMemory(InputStream is) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); copyStream(is, bos); bos.close(); return bos.toByteArray(); } public static void copyStream(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[4096]; int len; while ((len = in.read(buf)) > -1) { out.write(buf, 0, len); } } }