字节输入流一次读取多个字节

 1 package com.yhqtv.demo02.InputStream;
 2 
 3 import java.io.FileInputStream;
 4 
 5 
 6 /*
 7  * @author  XMKJ  yhqtv.com Email:yhqtv@qq.com
 8  * @create 2020-05-12-15:52
 9  *
10  */
11 public class Demo02InputStream {
12     public static void main(String[] args) throws Exception {
13         FileInputStream fis=new FileInputStream("C:\\666\\1hello.txt");
14 
15         byte[] bytes=new byte[1024];
16         int len;
17         while((len=fis.read(bytes))!=-1){
18             System.out.println(new String(bytes,0,len));
19         }
20 
21         fis.close();
22 
23     }
24 }

 

posted @ 2020-05-12 18:08  鑫淼  阅读(510)  评论(0)    收藏  举报