Here you can find the source of unescape(String str)
public static String unescape(String str)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 Business Objects Software Limited and others. * All rights reserved. // w ww . j ava 2s .c o m * This file is made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Business Objects Software Limited - initial API and implementation *******************************************************************************/ public class Main { public static String unescape(String str) { StringBuffer sb = new StringBuffer(str.length()); char[] array = str.toCharArray(); for (int cnt = 0; cnt < array.length; cnt++) { if (array[cnt] != '\\') { sb.append(array[cnt]); } else { switch (array[++cnt]) { case 'n': sb.append('\n'); break; case '\\': sb.append('\\'); break; case 'r': sb.append('\r'); break; default: break; } } } return sb.toString(); } }