Java String Dequote dequoteString(String strVal)

Here you can find the source of dequoteString(String strVal)

Description

Replaces all html/xml expressions for newline and carriage return within the given string value with their java counterpart, namely '\n' and '\r'.

License

Open Source License

Parameter

Parameter Description
strVal a parameter

Declaration

public static String dequoteString(String strVal) 

Method Source Code

//package com.java2s;
/*/*from w ww .  j  av a  2 s .c  o  m*/
*
* @file XMLUtil.java
*
* Copyright (C) 2006-2009 Tensegrity Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License (Version 2) as published
* by the Free Software Foundation at http://www.gnu.org/copyleft/gpl.html.
*
* 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*
* If you are developing and distributing open source applications under the
* GPL License, then you are free to use JPalo Modules under the GPL License.  For OEMs,
* ISVs, and VARs who distribute JPalo Modules with their products, and do not license
* and distribute their source code under the GPL, Tensegrity provides a flexible
* OEM Commercial License.
*
* @author Stepan Rutz
*
* @version $Id: XMLUtil.java,v 1.5 2009/04/29 10:21:58 PhilippBouillon Exp $
*
*/

public class Main {
    /**
     * Replaces all html/xml expressions for newline and carriage return within
     * the given string value with their java counterpart, namely '\n' and '\r'.
     * @param strVal
     * @return
     */
    public static String dequoteString(String strVal) {
        String newStr = strReplace(strVal, "
", "\r"); //$NON-NLS-1$ //$NON-NLS-2$
        return strReplace(newStr, "
", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    public static String strReplace(String string, String token, String replaceString) {
        String newStr = string;
        int i = string.indexOf(token);
        while (i > -1) {
            newStr = string.substring(0, i);
            newStr += replaceString;
            if (string.length() > (i + token.length())) {
                newStr += string.substring(i + token.length());
            }
            string = newStr;
            i = string.indexOf(token);
        }

        return newStr;
    }
}

Related

  1. dequoteFull(String str, char quote)
  2. dequoteIdentifier(String id)
  3. dequoteString(String s)
  4. dequoteString(String str)
  5. dequoteString(String str)
  6. deQuoteStringArray(String... quoted)