读取步骤:
- 创建字节流输出对象
- 读方法
- 释放资源
一次读一个字节数组的数据:
package File_Demo;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class File_demo7 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
FileInputStream file = new FileInputStream("D:\\JAVA\\java.txt");
byte[] b = new byte[1024];
int i = file.read(b);
System.out.println(i);
System.out.println(new String(b,0,i));
}
}