- import java.io.FileWriter;
- import java.io.IOException;
- public class FileWriterDemo3
- {
- public static void main(String[] args)
- {
- FileWriter fw = null;
- try
- {
- fw = new FileWriter("demo.txt",true);
- fw.write("nihao\nxiexie");
- }
- catch(IOException e)
- {
- System.out.println(e.toString());
- }
- finally
- {
-
- try {
- if(fw!=null)
- fw.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
复制代码
|
|