/**
     * 输入流转换成字符串
     * @param is
     * @param destCode
     * @return
     * @throws IOException
     */
    public static String readFromStream(InputStream is,String destCode) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        
        byte[] buffer = new byte[1024];
        
        int len = 0;
        
        while ((len = is.read(buffer)) != -1) {
            baos.write(buffer, 0, len);
        }
        
        is.close();
        
        String result = baos.toString(destCode);
        
        baos.close();
        
        return result;
    }

 

posted on 2015-08-18 23:41  cbooy  阅读(1274)  评论(0编辑  收藏  举报