Here you can find the source of unescape(String escaped)
public static String unescape(String escaped)
//package com.java2s; public class Main { public final static char ESCAPE_CHAR = '\\'; public static String unescape(String escaped) { boolean escaping = false; StringBuilder newString = new StringBuilder(); for (char c : escaped.toCharArray()) { if (!escaping) { if (c == ESCAPE_CHAR) { escaping = true;//from w w w . j a v a 2 s . c o m } else { newString.append(c); } } else { if (c == 'n') { newString.append('\n'); } else if (c == 'r') { newString.append('\r'); } else { newString.append(c); } escaping = false; } } return newString.toString(); } }