- import java.io.FileInputStream;
- import java.io.IOException;
- public class Test3 {
- public static void main(String[] args) throws IOException {
- FileInputStream fis = new FileInputStream("a.txt");
-
- byte[] bys = new byte[1024];
-
- //代码一
- int len = 0;
- while((len=fis.read(bys))!=-1){
- System.out.println(new String(bys,0,len));
- }
-
- //代码二
- int len = fis.read(bys);
- String s = new String(bys,0,len);
- System.out.println(s);
- }
- }
复制代码
代码一和代码二有什么区别。。求详细解释 |
|