Java tutorial
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static String inputStream2String(InputStream is) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] array = new byte[1024]; int len; while ((len = is.read(array, 0, array.length)) != -1) { baos.write(array, 0, len); } return baos.toString(); } catch (IOException e) { e.printStackTrace(); } return null; } }