- //Demo1903.java
- import java.io.*;
- class Demo1903
- {
- public static void main(String[] args)
- {
- BufferedWriter bw = null;
- BufferedReader br = null;
- try
- {
- bw = new BufferedWriter(new FileWriter("F:\\sql.txt"));
- //bw = new BufferedWriter(new FileWriter("F:\\sql.txt",true));
- br = new BufferedReader(new FileReader("D:\\sql.txt"));
- String str = null;
- while ((str = br.readLine())!=null)
- {
- bw.write(str);
- bw.newLine();
- bw.flush();
- }
- }
- catch (IOException e)
- {
- System.out.println(e.toString());
- }
- finally
- {
- try
- {
- if (bw != null)
- {
- bw.close();
- }
- }
- catch (IOException e)
- {
- System.out.println(e.toString());
- }
- try
- {
- if (br != null)
- {
- br.close();
- }
- }
- catch (IOException e)
- {
- System.out.println(e.toString());
- }
- }
- }
- }
复制代码 bw = new BufferedWriter(new FileWriter("F:\\sql.txt"));
bw = new BufferedWriter(new FileWriter("F:\\sql.txt",true));
这两行代码在这个程序中有什么区别?
为什么效果是一样的?
不是如果没有true原来的文本会被覆盖吗?
|