【java】之读取InputStream流
生活随笔
收集整理的這篇文章主要介紹了
【java】之读取InputStream流
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?如這個文件
?
@Testpublic void test01() throws Exception{InputStream in=new FileInputStream("c://test.txt");byte[] b=new byte[1024];ByteArrayOutputStream out=new ByteArrayOutputStream();int len=-1;while((len=in.read(b))!=-1){out.write(b,0,len);}out.close();in.close();String str= new String(out.toByteArray(),"UTF-8");System.out.println(str);}?
讀取結果
?
?
轉載于:https://www.cnblogs.com/gyjx2016/p/6068247.html
總結
以上是生活随笔為你收集整理的【java】之读取InputStream流的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 度小满保险怎么退掉
- 下一篇: iOS-改变UITextField的Pl