1.IO:输入/输出流:一组有序的、起点、终点
2.字节的集合:对数据传输的总称
3.输入:InputSream、输出:OutputSream这两是抽象类,它的实现类有:FileInputStream(文件流)、PipedInputSream(管道流)、DataInputStream(数据流)
import java.io.*;
public class Test {
public static void main(String args[]) throws Exception{
//1.返回的首字母
FileInputStream fin=new FileInputStream (“F://a.txt”);
System.out.println((char)fin.read());
fin.close();
//2.设置缓存区
FileInputStream fin2=new FileInputStream ("F://a.txt");
byte buff[]=new byte[1024];
while(fin2.read(buff)!=-1){
System.out.println(new String(buff));
}
fin2.close();
//3.写入数据
FileOutputStream fin3=new FileOutputStream ("F://a.txt");
String str="hello";
fin3.write(str.getBytes());
fin3.close();
System.out.println("end...");
}
}
4.new String (buff)字符串
5.available():可返回文件内容大小
6.skip(n):跳过N个字节读取
7.文件读取完关闭流close()
8.传输格式不同,分为字节流和字符流;流向不同分为输入流和输出流