- - - - | InputStream 所有输入字节流的基类,继承Object类。是abstract抽象类。
- - - - - - - - | FileInputStream 读取文件数据的输入字节流。
3.1 读取数据的步骤(使用FileInputStream读取文件数据)
1.找到目标文件 File file = new File("E:\\aa\\bb\\a.txt")
2.搭建数据传输通道(桥梁) FileInputStream fis = new FileInputStream(file);
3.传输数据(读取数据) fis.read()
4.关闭通道(释放资源)fis.close()
3.2 案例
public class Dome1 {
public static void main(String[] args) throws IOException {
// 1.确定目标文件
File file = new File("E:\\aa\\bb\\aaa.wmv");
// 2.搭建桥梁
FileInputStream fileInputStream = new FileInputStream(file);
// 3.读取数据
// 创建缓冲字节数组
byte[] bytes = new byte[1024 * 10];//存储读取到的数