I am working on a Java application which creates .docx files using Apache POI. However, "äöü" is not correctly displayed in the word file when I open it manually from the Intelij navigation after it was created. Do you have an idea what I might want to check/amend?
public void generateProtocolTEST() throws IOException {
if (!Paths.get("./protocols").toFile().exists()) Files.createDirectories(Paths.get("./protocols"));
XWPFDocument document = new XWPFDocument();
FileOutputStream out = new FileOutputStream("protocols/" + "test.docx");
document.createParagraph().createRun().setText("äüö");
document.write(out);
out.close();
}
Solution:
- Added "[compileJava, compileTestJava].options.encoding = 'UTF-8'" to build.gradle file.
- Build the project via the gradle navigation again.
- Restarted the IDE.