字节流:FileInputStream , FileOutputStream
public class IOdemo {
public static void main(String[] args) throws IOException {
File file = new File("F:\\hehe.txt");
FileInputStream in = new FileInputStream(file);
File f = new File("2.txt");
byte[] str = new byte[100];
in.read(str);//读文件信息
String s = new String(str);
System.out.println(s);
in.close();
File file1 = new File("F:\\hello.txt");
FileOutputStream out = new FileOutputStream(file1);
byte[] b = new byte[100];
String data = new String("hello wrold");
b = data.getBytes();
out.write(b);//写文件信息
out.close();
}
}
字符流:FileReader , FileWriter
字节流转字符流:InputStreamReader,OutputStreamWriter
缓冲流(字符串):BufferedReader , BufferedWriter
键盘输入流:System.in , 属于字节输入流
键盘输出流:System.out , 属于字节输出流
数据类型流:DataInputStream,DataOutputStream(字节流)
对象流:ObjectInputStream,ObjectOutputStream(字节流)