1 package cn.itsource._inputsteam; 2 3 import java.io.FileNotFoundException; 4 import java.io.FileWriter; 5 import java.io.IOException; 6 7 public class FileWriterTest { 8 9 /* 10 * 该类用于字符输出流: 11 * 就是把内存的数据存储到硬盘中去 12 * 构造方法 13 * 1.FileWriter(File file) 14 * 2.FileWriter(String filename) 15 * filename:文件名(相对路径或者绝对路径) 16 */ 17 public static void main(String[] args) throws IOException { 18 FileWriter fw = null; 19 try { 20 fw = new FileWriter("E:/洛晟.txt"); 21 int read = 1; 22 // char[] c = new char[10]; 23 fw.write("再见雨梨"); 24 System.out.println("执行完毕"); 25 } catch (FileNotFoundException e) { 26 e.printStackTrace(); 27 } catch (IOException e){ 28 e.printStackTrace(); 29 } finally { 30 //关流,调用自己封装的功能,没有的流直接传null 31 IOUtil.closeIO(null, fw); 32 } 33 34 35 } 36 37 }
标签:11,java,22,fw,IOException,2022,import,FileWriter From: https://www.cnblogs.com/puwei520/p/16916714.html