I/O小结

1 读写字符文件
  BufferedReader br = new BufferedReader (new FileReader("文件路径"));
  BufferedWriter br = new BufferedWriter (new FileWriter("文件路径",boolean));


2 读取字节文件
  DataInputStream dis = new DataInputStream(new FileInputStream("文件路径"));
  DataOutputStream dis = new DataOutputStream(new FileOutputStream("文件路径"));

3 读取整个字符文件
  String str = null;
  while((str=br.readLine())!=null){
    System.out.println(str);
  }


4读取整个字节文件
  int b;
  while((b=dis.read())!=-1){
    System.out.println(b);
  }

posted @ 2017-06-07 14:56  孤独患者xy  阅读(114)  评论(0编辑  收藏  举报