Here you can find the source of unescapeJava(final String str)
public static String unescapeJava(final String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String unescapeJava(final String str) { final char[] chars = str.toCharArray(); final StringBuilder sb = new StringBuilder(str.length()); for (int i = 0; i < chars.length; ++i) { char c = chars[i]; if (c != '\\') { sb.append(c);/*w ww .j ava 2 s. co m*/ } else { ++i; c = chars[i]; switch (c) { case 'b': { sb.append('\b'); break; } case 't': { sb.append('\t'); break; } case 'n': { sb.append('\n'); break; } case 'f': { sb.append('\f'); break; } case 'r': { sb.append('\r'); break; } case '\"': { sb.append('\"'); break; } case '\\': { sb.append('\\'); break; } case 'u': { final char hex = (char) Integer.parseInt(new String(chars, i + 1, 4), 16); sb.append(hex); i += 4; break; } default: { throw new IllegalArgumentException("Invalid escaping character: " + c); } } } } return sb.toString(); } public static String toString(final Object value) { if (value == null) { return null; } return value.toString(); } }