[Solved] Java scanner reading garbage


You are reading a RTF Document. If you want to read the text only you can try reading it into a byte array and parsing out the text using swings rtfeditorkit.

Path path = Paths.get("path/to/file");
byte[] data = Files.readAllBytes(path);

RTFEditorKit rtfParser = new RTFEditorKit();
Document document = rtfParser.createDefaultDocument();
rtfParser.read(new ByteArrayInputStream(data), document, 0);
String text = document.getText(0, document.getLength());

solved Java scanner reading garbage