Java String Escape percentEncode(String value, String encoding)

Here you can find the source of percentEncode(String value, String encoding)

Description

percent Encode

License

Apache License

Declaration

public static String percentEncode(String value, String encoding)
            throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;
// | Licensed under the Apache License, Version 2.0 (the "License");

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Main {
    public static String percentEncode(String value, String encoding)
            throws UnsupportedEncodingException {
        return value != null ? URLEncoder.encode(value, encoding)
                .replace("+", "%20").replace("*", "%2A")
                .replace("%7E", "~") : null;
    }/*from   w w  w  .  j  a  va  2 s.  c o m*/
}

Related

  1. escapeXml(String str)
  2. escapeXML(String str)
  3. percentEncode(String s)
  4. percentEncode(String s)
  5. percentEncode(String value)
  6. percentEncodeRfc3986(final String string)