RTF Line count in Java
问题 Kindly let me know any API to calculate the line count for RTF document. Apache POI or Aspose works for document, but its not able to find line count for RTF. Thanks. 回答1: Java already has a built-in RTF-Parser: RTFEditorKit. Take a look at its read method. For example: test.rtf file contents hello stackoverflow users So, it has 3 lines separated by \n . Code: FileInputStream stream = new FileInputStream("test.rtf"); RTFEditorKit kit = new RTFEditorKit(); Document doc = kit