Java String Encode encodeDoublePercent(String input)

Here you can find the source of encodeDoublePercent(String input)

Description

encode Double Percent

License

Mozilla Public License

Declaration

public static String encodeDoublePercent(String input) 

Method Source Code

//package com.java2s;
//     The contents of this file are subject to the Mozilla Public License

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    public static String encodeDoublePercent(String input) {
        if (input.contains("%")) {
            input = input.replaceAll("%", "%25");
        }// w  ww .ja  v a  2  s.co  m
        return encode(input);
    }

    public static String encode(String input) {
        try {
            return URLEncoder.encode(input, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. encode(String val, String encoding)
  2. encode(String value, String encoding)
  3. encodeBase64(String str)
  4. encodeConvenience(String str)
  5. encodeDataPair(final StringBuilder buffer, final String key, final String value)
  6. encodeDownloadFileName(String s)
  7. encodeFilename(final String filename, final String userAgent)
  8. encodeFilename(String filename, String encoding)
  9. encodeFilenameOmittingWhiteSpaces(String filename, String encoding)