Here you can find the source of unescape(String s)
Parameter | Description |
---|---|
s | the String to unescape |
public static String unescape(String s)
//package com.java2s; /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved. * This code is licensed under the GPL 2.0 license, availible at the root * application directory.//from w w w.j av a 2 s .c om */ public class Main { /** * Resolve escape sequences in a String. * * @param s the String to unescape * * @return resolved String */ public static String unescape(String s) { if (s == null) { throw new IllegalArgumentException( "The String to unescape may not be null."); } StringBuilder sb = new StringBuilder(); boolean escaped = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (escaped) { escaped = false; sb.append(c); } else if (c == '\\') { escaped = true; } else { sb.append(c); } } if (escaped) { throw new IllegalArgumentException( "The specified String ends with an incomplete escape sequence."); } return sb.toString(); } }