Java String Unescape unescape(String str)

Here you can find the source of unescape(String str)

Description

unescape

License

Open Source License

Declaration

public static String unescape(String str) 

Method Source Code

//package com.java2s;
/*/* w  ww  . j  a v a2 s .c  o m*/
 * Tigase XMPP Client Library
 * Copyright (C) 2006-2014 Tigase, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. Look for COPYING file in the top folder.
 * If not, see http://www.gnu.org/licenses/.
 */

public class Main {
    private static final String[][] ENTITIES = { { "&", "&amp;" }, { "<", "&lt;" }, { ">", "&gt;" },
            { "\"", "&quot;" }, { "'", "&apos;" }, };

    public static String unescape(String str) {
        if (str == null)
            return null;
        if (str.length() == 0)
            return str;
        for (int i = ENTITIES.length - 1; i >= 0; i--) {
            str = str.replace(ENTITIES[i][1], ENTITIES[i][0]);
        }
        return str;
    }
}

Related

  1. unescape(String src)
  2. unescape(String st)
  3. unescape(String str)
  4. unescape(String str)
  5. unescape(String str)
  6. unescape(String str)
  7. unescape(String str)
  8. unescape(String str)
  9. unescape(String str)