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 { public static String InputStream2String(final InputStream is) { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length = 0; while ((length = is.read(buffer)) != -1) { baos.write(buffer, 0, length); } return baos.toString(); } catch (IOException e) { e.printStackTrace(); } return null; } }