数据流InputStream转字符串
生活随笔
收集整理的這篇文章主要介紹了
数据流InputStream转字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
public static String ScreamToString(InputStream in) throws Exception{//定義一個內存輸出流ByteArrayOutputStream out = new ByteArrayOutputStream();int len=0;byte[] bt=new byte[1024];while((len=in.read(bt))!=-1){out.write(bt,0,len);}String content=new String(out.toByteArray());//使用構造函數的原因是//還可以通過new String(out.toByteArray(),"utf-8")來設置編碼return content;}
轉載于:https://www.cnblogs.com/gwd1154978352/p/6831905.html
總結
以上是生活随笔為你收集整理的数据流InputStream转字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: django-xadmin使用之更改菜单
- 下一篇: maven+SSM框架工程搭建