Java Utililty Methods URL Encode

List of utility methods to do URL Encode

Description

The list of methods to do URL Encode are organized into topic(s).

Method

StringurlEncodeForSpaces(String input)
This method encodes the url, removes the spaces from the url and replaces the same with "%20".
return urlEncodeForSpaces(input.toCharArray());
StringurlEncodeForSpaces(String input)
This method encodes the URL, removes the spaces from the URL and replaces the same with "%20".
if (input == null) {
    return null;
return urlEncodeForSpaces(input.toCharArray());
StringurlEncodeParameter(String value)
url Encode Parameter
char[] chars = value.toCharArray();
StringBuilder sb = new StringBuilder();
for (char character : chars) {
    if (character == '&')
        sb.append("%26");
    else if (character == '=')
        sb.append("%3D");
    else if (character == '#')
...
StringURLEncoder(String str)
URL Encoder
if (str == null) {
    return null;
StringBuffer resultStr = new StringBuffer(str.length());
char tmpChar;
for (int ix = 0; ix < str.length(); ix++) {
    tmpChar = str.charAt(ix);
    switch (tmpChar) {
...
StringurlEncodeSpace(String s)
_more_
return s.replaceAll(" ", "+");
StringurlParameterEncode(String s)
like urlEncode, but adds the equal sign
boolean changed = false;
char c;
StringBuffer sb = null;
for (int i = 0; i < s.length(); i++) {
    c = s.charAt(i);
    if (c == ' ' || c == '+' || c == '<' || c == '&' || c == '>' || c == '"' || c == '\'' || c == '='
            || c > 0x7f) {
        if (!changed) {
...
char[]urlPercentEncodeTwo(char c)
url Percent Encode Two
char[] result = null;
int ci = c;
int leftNibble = (0xF0 & ci) >> 4;
int rightNibble = (0x0F & ci);
result = new char[] { PERCENT_SYMBOL, HEX_TO_CHAR[leftNibble], HEX_TO_CHAR[rightNibble] };
return result;