Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; public class Main { public static String getStringFromStream(InputStream is) { byte[] bytes = new byte[1024]; int len = 0; String res = ""; try { while ((len = is.read(bytes)) != -1) { res = res + new String(bytes, 0, len, "gbk"); } } catch (IOException e) { e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } return res; } }