Pessoal,
Estou usando essa função para utilização de caracteres especiais:
private String HTMLfy(String s) {
String str = s.replaceAll("<span class=\"msg_sender\">", "").replaceAll("</span>", "").replaceAll("<br>", "\n");
str = str.replaceAll("ã", "ã").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("õ", "õ").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("á", "á").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("é", "é").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("í", "í").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ó", "ó").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ú", "ú").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ý", "ý").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("â", "â").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ê", "ê").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ô", "ô").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("î", "î").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("û", "û").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ç", "ç").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("à", "à").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("è", "è").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ì", "ì").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ò", "ò").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ù", "ù").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ù", "Ù").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ò", "Ò").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ì", "Ì").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("È", "È").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("À", "À").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ä", "ä").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ë", "ë").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ï", "ï").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ö", "ö").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ü", "ü").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ü", "Ü").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ö", "Ö").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ï", "Ï").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ë", "Ë").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ä", "Ä").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ÿ", "ÿ").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ñ", "ñ").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ñ", "Ñ").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ã", "Ã").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Õ", "Õ").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Á", "Á").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("É", "É").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Í", "Í").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ó", "Ó").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ú", "Ú").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ý", "Ý").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Â", "Â").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ê", "Ê").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ô", "Ô").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Î", "Î").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Û", "Û").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("Ç", "Ç").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("¨", "¨").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("§", "§").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("ª", "ª").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("º", "º").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("°", "°").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("´", "´").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("%", "%").replaceAll("\n", "<br>").replaceAll("\r", "");
str = str.replaceAll("&", "%26").replaceAll("+", "%2B").replaceAll("#", "%23");
return str;
}//HTMLfy
quando tento enviar me retorna esse erro:
java.util.regex.PatternSyntaxException: Dangling meta character ‘+’ near index 0
+
^
at java.util.regex.Pattern.error(Pattern.java:1650)
at java.util.regex.Pattern.sequence(Pattern.java:1787)
at java.util.regex.Pattern.expr(Pattern.java:1687)
at java.util.regex.Pattern.compile(Pattern.java:1397)
at java.util.regex.Pattern.(Pattern.java:1124)
at java.util.regex.Pattern.compile(Pattern.java:817)
at java.lang.String.replaceAll(String.java:2000)
at br.com.cpqd.www.dmd.chat.ChatFrame.HTMLfy(ChatFrame.java:322)
at br.com.cpqd.www.dmd.chat.ChatFrame.jButton1ActionPerformed(ChatFrame.java:183)
at br.com.cpqd.www.dmd.chat.ChatFrame.access$000(ChatFrame.java:31)
at br.com.cpqd.www.dmd.chat.ChatFrame$1.actionPerformed(ChatFrame.java:82)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Alguém pode me ajudar?