import java.io.UnsupportedEncodingException;
public class Encode_Decode {
public static void main(String[] args) {
String url = "これはtest_[]です<>()!#^$@%~&*";
try {
String urlencode = java.net.URLEncoder.encode(url, "UTF-8");
System.out.println("エンコーディング: "+urlencode);
文字列 urldecode = java.net.URLDecoder.decode(urlencode, "UTF-8");
System.out.println("デコード: "+urldecode);
} catch (UnsupportedEncodingException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
}
}
コーディング: This+is+a+test_%5B%5D%3C%3E%28%29%21%23%5E%24%40%25%7E%26*このプログラムでは、URLEncoder.encoder.encoderメソッドでString urlencode変数を引数として渡し、結果を表示します。次に、 URLDecoder.decode デコードされた url.
Decode: これは test_[]です<>()!#^$@%~&*
Please disable your ad blocker and refresh the window to use this website.