使用URLEncoder进行url编码
//package com.nowjava;/* 来 自 n o w j a v a . c o m*/ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static void main(String[] argv) throws Exception { String input = "nowjava.com"; String charset = "nowjava.com"; System.out.println(urlEncode(input, charset)); } public static String urlEncode(String input, String charset) { try { return URLEncoder.encode(input, charset); } catch (