BufferRead/Writer的使用

//BufferedReader和BufferedWriter的应用
 
 public static void main(String[] args) {
  FileReader fr;
  FileWriter fw;
  BufferedReader br;
  BufferedWriter bw;
  try {
   fr = new FileReader(“d:/student.sql”);
   br=new BufferedReader(fr卡塔尔(قطر‎;//每多个BufferedWriter都出自于FileReader
   fw=new FileWriter(“d:/student1.sql”);
   bw=new BufferedWriter(fw);
   String
s=br.readLine(卡塔尔国;//将读出来的原委发到字符串中,而且是单排的生龙活虎行读下来的。
   
   while(s!=null){
    bw.write(s卡塔尔国;//将BufferedReader的内存放到BufferedWrieter中
    bw.newLine(State of Qatar;//为了在每大器晚成读取时,加四个换行符
    s=br.readLine();
   }
   bw.close();
   fw.close();
   br.close();
   fr.close(卡塔尔;//唯有当关闭写入流之后,文件的内存本领读到此中
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }