输入流转换成字符串

来源:互联网 发布:超星阅览器 mac 编辑:程序博客网 时间:2024/05/10 14:24
public  class Utils {    public static String getTextFromStream(InputStream is){        int len=0;        byte[] b=new byte[1024];        ByteArrayOutputStream baos=new ByteArrayOutputStream();        try {            while((len=is.read(b))!=-1){                baos.write(b,0,len);            }        } catch (IOException e) {            e.printStackTrace();        }        String text=new String(baos.toByteArray());        return text;    }}
0 0
原创粉丝点击