Here you can find the source of unescape(String s)
static String unescape(String s)
//package com.java2s; //License from project: Open Source License public class Main { static String unescape(String s) { if (s == null) return null; if (s.equals("")) return null; StringBuilder result = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '\\') { if (i + 1 == s.length()) throw new IllegalArgumentException( "The last character of the input may not be a \\!"); i++;/*from w w w.ja v a2 s . com*/ char c = s.charAt(i); switch (c) { case 'n': result.append("\n"); break; case 't': result.append("\t"); break; case '\\': result.append("\\"); break; case '"': result.append("\""); break; default: throw new IllegalArgumentException( "Unexpected escape sequence \\" + c + "!"); } } else result.append(s.charAt(i)); } return result.toString(); } }