package com.seven.inputStreamReader; import java.io.*; public class TestInputStreamReader { public static void main(String[] args)throws Exception { InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream("D:\a.txt"),"gbk"); char[] chars = new char[1024]; while (true){ int read = inputStreamReader.read(chars); if (read==-1)break; System.out.println(new String(chars,0,read)); } inputStreamReader.close(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream("d:\q.txt"),"gbk"); for (int i = 0; i < 9; i++) { outputStreamWriter.write("aaaaaa中国人n"); outputStreamWriter.flush(); } outputStreamWriter.close(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)