Here you can find the source of toJava(String text)
The following characters are replaced with corresponding character entities :
Character | Encoding |
---|---|
< | < |
> | > |
& | & |
" | " |
' | ' |
public static String toJava(String text)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w . j ava 2 s . c o m Transforms special characters in characters understandable for java <P>The following characters are replaced with corresponding character entities : <table border='1' cellpadding='3' cellspacing='0'> <tr><th> Character </th><th> Encoding </th></tr> <tr><td> < </td><td> < </td></tr> <tr><td> > </td><td> > </td></tr> <tr><td> & </td><td> & </td></tr> <tr><td> " </td><td> "</td></tr> <tr><td> ' </td><td> '</td></tr> </table> */ public static String toJava(String text) { return text.replace("<", "<").replace(">", ">").replace(""", "\"").replace("'", "\'") .replace("&", "&"); } }