StringUtil


    //将字节输入流转为字符串
    public static String readStream(InputStream is){
        try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;

            while ((len = is.read(buffer)) != -1){
                bos.write(buffer,0,len);
            }
            is.close();
            return bos.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }


你可能感兴趣的:(StringUtil)