Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; public class Main { public static String byteArrayOutStreamToString(ByteArrayOutputStream outputStream) { byte[] buf = outputStream.toByteArray(); try { return new String(buf, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); return ""; } } }