此处使用了“utf-8”,避免了乱码问题,BufferedWriter也可以用 PrintWriter代替。
public static void readFile2File(String src,String dst) throws Exception{
//注意此处的字符集
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(src),"utf-8"));
String line = null;
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dst),"utf-8"));
while((line=br.readLine())!=null){
bw.write(line);
bw.newLine(); //换行
// bw.flush();
}
br.close();
bw.close();
}