标签:txt writer 编码 input span 装饰者模式 文件操作 logs utf-8
FileOutputStream fos = new FileOutputStream("test.txt"); OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); osw.write(FileContent); osw.flush();
以utf-8编码读取文件:
FileInputStream fis = new FileInputStream("test.txt"); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { FileContent += line; FileContent += "\r\n"; // 补上换行符 }
标签:txt writer 编码 input span 装饰者模式 文件操作 logs utf-8
原文地址:http://www.cnblogs.com/gengaixue/p/6684087.html