How To Convert rtf To String In Java?
Manohar Changed status to publish October 8, 2019
public String convertRtfToText(String fareRules) throws IOException, BadLocationException { try { byte[] x = Base64.getDecoder().decode(fareRules.getBytes()); RTFEditorKit rtfParser = new RTFEditorKit(); Document document = rtfParser.createDefaultDocument(); rtfParser.read(new ByteArrayInputStream(x), document, 0); String fareRuleText = document.getText(0, document.getLength()); return fareRuleText; } catch (Exception e) { //here write logs } return fareRules; }
Use above code ,hope it will work.
Manohar Changed status to publish October 8, 2019