1.DtaInputStream(字节流类读二进制文件)
构造一个输入流对象:
DataInputStream dis=new DataInputStream(new FileInputStream("src/a.jpg"));
dis.read();//读取数据字节
dis.close();//关闭输入流
2.DtaOutputStream
DataOutputStream dos=new DataOutputStream(new FileOutputStream("src/b.jpg);
dos.write(255);//指定字节数据写如文件
dos.close();//关闭输出流
3.字符文件 :
BufferedReader br=new BufferedReader (new FileReader("文件"));
BufferedWriter bw =new BufferedWriter(new FileWriter("文件",boolean));
4.字节文件:
DataInputStream dis=new DataInputStream(new FileInputStream("文件"));
DataOutputStream dos=new DataOutputStream(new FileOutputStream("文件"));
5.整个字符文件:
String str=null;
while((str =br.readLine())!=null){
System.out.println(str);
}
6.整个字节文件:
int b;
while((b=d.read())!=-1){
dos.write(b);
System.out.println((char)b);
}