Java HTML Escape htmlEscapeSpace(String uri)

Here you can find the source of htmlEscapeSpace(String uri)

Description

html Escape Space

License

Open Source License

Declaration

public static StringBuffer htmlEscapeSpace(String uri) 

Method Source Code

//package com.java2s;
/*//from w ww.  j a  v a2 s .  c  o m
 * {{{ header & license
 * GeneralUtil.java
 * Copyright (c) 2004, 2005 Patrick Wright
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser 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.
 * }}}
 */

public class Main {
    public static StringBuffer htmlEscapeSpace(String uri) {
        StringBuffer sbURI = new StringBuffer((int) (uri.length() * 1.5));
        char ch;
        for (int i = 0; i < uri.length(); ++i) {
            ch = uri.charAt(i);
            if (ch == ' ') {
                sbURI.append("%20");
            } else if (ch == '\\') {
                sbURI.append('/');
            } else {
                sbURI.append(ch);
            }
        }
        return sbURI;
    }
}

Related

  1. htmlEscape(String tag)
  2. htmlEscape(String text)
  3. htmlescapeAll(String s1)
  4. htmlEscapeBasicMarkup(final String text)
  5. HTMLEscapeBr(String original)
  6. htmlUnescape(String safeHtml)