12345678910111213141516171819202122232425262728293031323334353637 |
- package com.day19.io01;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.util.Arrays;
- /**
- * ClassName: Test01
- *
- * @Author 爱扣钉-陈晨
- * @Create 2024/1/17 9:44
- * @Version 1.0
- */
- public class Test04 {
- public static void main(String[] args) throws IOException {
- //循环读取文件
- FileInputStream fis = new FileInputStream("day19\\file\\b.txt");
- //数组
- byte[] bytes = new byte[2];
- int l1 = fis.read(bytes);
- System.out.println(l1);
- System.out.println(Arrays.toString(bytes));
- int l2 = fis.read(bytes);
- System.out.println(l2); //读取到一个
- System.out.println(Arrays.toString(bytes));
- new String(bytes,0,1);
- //释放资源
- fis.close();
- }
- }
|