Share this page 

Unquote a StringTag(s): String/Number

We use the fact that the Properties unquote a String, so we simply simulate a Property read with our String.

Maybe not the best way but it is certainly very easy!

import java.util.*;

public class Unquote {
   public static void main(String[] args) {
      String a = "Visit Real\\'s at";
      String b = unquote(a);
      output :
      Visit Real\'s at
      Visit Real's at

   public static String unquote(String a) {
      Properties prop = new Properties();
      try {
         prop.load(new ByteArrayInputStream(("x=" + a).getBytes()));
      catch (IOException ignore) {}
      return prop.getProperty("x");