其他分享
首页 > 其他分享> > 转换流

转换流

作者:互联网

@Test
    public void test4() throws IOException {
        InputStreamReader isr = null;
        try {
            FileInputStream fis = new FileInputStream("D:\\java.txt");
            isr = new InputStreamReader(fis,"UTF-8");
            char[] cbuf = new char[5];
            int len = 0;
            while ((len = isr.read(cbuf))!=-1){
                System.out.print(new String(cbuf,0,len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(isr!=null)
                isr.close();
        }
    }

  

标签:转换,isr,len,char,FileInputStream,new,cbuf
来源: https://www.cnblogs.com/ixtao/p/16647857.html