我有一个包含汉字文本的文件,我想将这些文本复制到另一个文件中。但是文件输出与中文字符混淆。请注意,在我的代码中,我已经使用“UTF8”作为我的编码:
BufferedReader br = new BufferedReader(new FileReader(inputXml));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append("\n");
line = br.readLine();
}
String everythingUpdate = sb.toString();
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outputXml), "UTF8"));
out.write("");
out.write(everythingUpdate);
out.flush();
out.close();