日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

回顾inputstream和outputstream

發(fā)布時(shí)間:2025/5/22 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 回顾inputstream和outputstream 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
@RequestMapping("input")public void input() throws IOException {File file=new File("D:"+ File.separator+"test.txt");InputStream in=new FileInputStream("D:"+ File.separator+"test.txt");//字節(jié)轉(zhuǎn)字符 防止亂碼InputStreamReader re=new InputStreamReader(in,"gbk");char[] b= new char[1024];int length;length= re.read(b);System.out.println(length);System.out.println(new String(b,0,length));}@RequestMapping("out")public void out(){try {String str="asdfghj歡迎來來到輸出流 寫入";char[] len=str.toCharArray();byte[] len1=str.getBytes();FileOutputStream in=new FileOutputStream("D:"+ File.separator+"test.txt");//字節(jié)轉(zhuǎn)字符 防止亂碼OutputStreamWriter wr=new OutputStreamWriter(in,"gbk");wr.write(len,0,len.length);wr.close(); //記得要關(guān)閉,否則無效果} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

總結(jié)

以上是生活随笔為你收集整理的回顾inputstream和outputstream的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。