Here you can find the source of unescape(String s)
public static String unescape(String s)
//package com.java2s; //License from project: Apache License public class Main { public static String unescape(String s) { if (s.indexOf('\\') < 0) return s; StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '\\' && i != (s.length() - 1)) { char c2 = s.charAt(i + 1); switch (c2) { case 'd':// dot sb.append("."); i++;/*from ww w. j a v a2s . c o m*/ break; case 's':// space sb.append(" "); i++; break; case 'b':// back slash sb.append("\\"); i++; break; default: throw new RuntimeException("failed to unescape string:" + s); } } else sb.append(c); } return sb.toString(); } }