Java URL Encode encode(String src, String srcCode, String destCode)

Here you can find the source of encode(String src, String srcCode, String destCode)

Description

encode

License

Open Source License

Declaration

public static String encode(String src, String srcCode, String destCode) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    public static String encode(String src, String srcCode, String destCode) {
        try {// w ww . j  av a  2s . co m
            byte[] strby = src.getBytes(srcCode);
            String dest = new String(strby, destCode);
            return dest;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String encode(String str) {
        try {
            return URLEncoder.encode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Broken VM does not support UTF-8");
        }
    }
}

Related

  1. encode(String s)
  2. encode(String s)
  3. encode(String s, String enc)
  4. encode(String s, String encoding)
  5. encode(String source)
  6. encode(String str)
  7. encode(String str)
  8. encode(String string)
  9. encode(String strInput)