try {
    FileOutputStream fos = new FileOutputStream("c:\\name.txt");
catch (Exception e) { }
只要你不关闭输出流,文件就会被清空。