如这个文件

【java】之读取InputStream流

 

    @Test
    public 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);
    }

 

读取结果

 

【java】之读取InputStream流

 

相关文章:

  • 2021-05-22
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
相关资源
相似解决方案