Here you can find the source of unquote(String str)
public static String unquote(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String unquote(String str) { assert isQuoted(str) : "Trying to unquote an unquoted string: " + str; // Detect which types of quotes are used and unescape accordingly. char qval = str.charAt(0); // Strip the existing quotes first. str = str.substring(1, str.length() - 1); if (qval == '\'') { str = str.replace("\\'", "'"); } else {// w w w . j a va2 s.co m assert qval == '"' : "Unknown quoted string format: " + str; str = str.replace("\\\"", "\""); } return str; } public static boolean isQuoted(String str) { if (str.startsWith("\"") && str.endsWith("\"")) return true; if (str.startsWith("'") && str.endsWith("'")) return true; return false; } }