inputstream与其他格式的转换

 

1、InputStream 转换成InputSource 。

InputStream inputStream = request.getInputStream();
InputSource input = new InputSource(inputStream);

2、InputStream 输出转换成字符串输出。

InputStream inputStream = request.getInputStream();

        StringBuffer   out   =   new   StringBuffer(); 
        byte[]   b   =   new   byte[4096]; 
        for   (int   n;   (n   =   inputStream .read(b))   !=   -1;)  

        { 
                out.append(new   String(b,   0,   n)); 
        } 
        String value = out.toString();

 

 

posted on 2014-07-09 19:53  随风浪子的博客  阅读(1625)  评论(0编辑  收藏  举报

导航