0

I have string which contains substrings like \u0022, \u003C, \n and want to replace them by the characters they stand for. What's the most straight forward way? Of course I could do something like

code = code.replaceAll("\\\\u003C", "<");

for each such character, but that's a little bit annoying.

Edit: To make it clear, I have already a string like

code="Hello \\u0022 World \\n \\u003C And so on.";
principal-ideal-domain
  • 3,998
  • 8
  • 36
  • 73

1 Answers1

1
public static void main(String[] args) throws FileNotFoundException, IOException {
    Properties properties = new Properties();
    String str = "unicodedString=Hello \\u0022 World \\n \\u003C And so on.";
    StringReader stringReader = new StringReader(str);
    properties.load(stringReader);
    System.out.println(properties.getProperty("unicodedString"));
}

output

Hello " World 
 < And so on.
Amit Kumar Lal
  • 5,537
  • 3
  • 19
  • 37