Java URL Encode encode(String toBeEncoded, String charSet, String defaultReturnValue)

Here you can find the source of encode(String toBeEncoded, String charSet, String defaultReturnValue)

Description

encode

License

Apache License

Declaration

public static String encode(String toBeEncoded, String charSet, String defaultReturnValue) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.URLEncoder;

public class Main {
    public static String encode(String toBeEncoded, String charSet, String defaultReturnValue) {
        String encodedString;/* w ww  .jav  a  2s.c o m*/
        try {
            encodedString = URLEncoder.encode(toBeEncoded, charSet);
        } catch (Exception var5) {
            System.err.println(String.format("Error when url-encode:%s with charset:%s",
                    new Object[] { toBeEncoded == null ? "" : toBeEncoded, charSet == null ? "" : charSet }));
            var5.printStackTrace();
            encodedString = defaultReturnValue;
        }

        return encodedString;
    }
}

Related

  1. encode(String str)
  2. encode(String str)
  3. encode(String string)
  4. encode(String strInput)
  5. encode(String text)
  6. encode(String value)
  7. encode(String value)
  8. encode(String value)
  9. encode(String value)