텍스트 (ukranian 기호)가 포함 된 파일이 하나 있습니다. 예 : ${name} - привіт
. ${name}
에서 Саша
으로 바꿔야합니다. 그러나 출력 파일에서 나는 같은 것을 대신에 пÑ??Ð¸Ð²ÐµÑ - привіт
과 같은 것으로 암송합니다. 하지만 대신 .txt를 사용하면 .rtf - 모두 괜찮습니다. 코딩 문제는 이해하지만 해결할 수는 없습니다.org.apache.commons.io.FileUtils - 텍스트 인코딩 변경
코드 예제 :
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();