将InputStream(输入流)转成String 的方法

来源:互联网 发布:淘宝首页轮播图片尺寸 编辑:程序博客网 时间:2024/05/28 17:05
public static String readInputStream(FileInputStream inStream) {    try {        ByteArrayOutputStream outStream = new ByteArrayOutputStream();        byte[] buffer = new byte[1024];        int length = -1;        while ((length = inStream.read(buffer)) != -1) {            outStream.write(buffer, 0, length);        }        outStream.close();        inStream.close();        return outStream.toString();    } catch (IOException e) {        Log.i("FileTest", e.getMessage());    }    return null;}
0 0
原创粉丝点击