テキスト(ウクライナの記号)を含むファイルが1つあります。例: ${name} - привіт
. ${name}
からに置き換える必要がありСаша
ます。しかし、出力ファイルでは、次のようなものを受け取りпÑ??Ð¸Ð²ÐµÑ - привіт
ますСаша- привіт
。しかし、.rtf の代わりに .txt を使用すると、すべて問題ありません。コーディングの問題は理解できますが、解決できません。
コード例:
File file = new File("original.rtf");
String content = FileUtils.readFileToString(file);
content = content.replace("${name}", "Саша");
File fileNew = new File("changed.rtf");
FileOutputStream fop = new FileOutputStream(fileNew);
byte[] contentInBytes = content.getBytes("UTF-8");
fop.write(contentInBytes);
fop.flush();
fop.close();