java读写文件
1. File("e:/1.xml", content);
2. //System.out.println(sb);
3. } catch (Exception e) {
4. e.printStackTrace();
5. }
6. } else {
7. System.out.println("文件不存在!");
8. }
9. }
10.
11. public static void writeFile(String filePathAndName, String fileContent) {
12. try {
13. File f = new File(filePathAndName);
14. if (!f.exists()) {
15. f.createNewFile();
16. }
17. OutputStreamWriter write = new OutputStreamWriter(
18. new FileOutputStream(f), "UTF-8");
19. BufferedWriter writer = new BufferedWriter(write);
20. writer.write(fileContent);
21. writer.close();
22. } catch (Exception e) {
23. System.out.println("写文件内容操作出错");
24. e.printStackTrace();
25. }
26. }
补充:软件开发 , Java ,