本文共 582 字,大约阅读时间需要 1 分钟。
package imcoo.com;
import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import jdk.jfr.events.FileWriteEvent; public class frAndfwDame { /** * @param args */ public static void main(String[] args)throws IOException { // TODO Auto-generated method stub FileReader fr =new FileReader("C:\\Users\\Hano\\Desktop\\123.txt"); FileWriter fw=new FileWriter("C:\\Users\\Hano\\Desktop\\1234.txt"); char []buffer =new char [1024]; int c; while((c=fr.read(buffer,0,buffer.length))!=-1){ fw.write(buffer,0,c); } fw.close(); } }说明:使用FileReader比较简单,但是时只能是默认的编码方式“gbk”
转载地址:http://rdlbi.baihongyu.com/