写入文件 @param fileName @param s @throws IOException
(String fileName, String s)
| 79 | * @throws IOException |
| 80 | */ |
| 81 | public static void writeToFile(String fileName, String s) throws IOException { |
| 82 | File f1 = new File(fileName); |
| 83 | OutputStream out = null; |
| 84 | BufferedWriter bw = null; |
| 85 | if (f1.exists()) { |
| 86 | out = new FileOutputStream(f1); |
| 87 | bw = new BufferedWriter(new OutputStreamWriter(out, "utf-8")); |
| 88 | bw.write(s); |
| 89 | bw.flush(); |
| 90 | bw.close(); |
| 91 | } else { |
| 92 | System.out.println("文件不存在"); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * 追加文件 |