Java HTML Encode HTMLEncode(String s)

Here you can find the source of HTMLEncode(String s)

Description

HTML Encode

License

Open Source License

Declaration

public static String HTMLEncode(String s) 

Method Source Code

//package com.java2s;
/*//from  w w  w.j av a2 s.c o m
 * Copyright (C) 2012 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {
    private static final String c[] = { "<", ">" };
    private static final String expansion[] = { "&lt;", "&gt;" };

    public static String HTMLEncode(String s) {
        for (int j = 0; j < c.length; j++) {
            s = s.replace(c[j], expansion[j]);
        }
        return s;
    }
}

Related

  1. htmlEncode(String s)
  2. htmlEncode(String s)
  3. htmlEncode(String s)
  4. htmlEncode(String s)
  5. htmlEncode(String s)
  6. htmlEncode(String s, boolean encodeSpecialChars)
  7. htmlEncode(String s, boolean encodeWS)
  8. HtmlEncode(String str)
  9. HTMLEncode(String str)