ParseQS and Global made into packages
This commit is contained in:
33
src/main/java/com/github/nkzawa/global/Global.java
Normal file
33
src/main/java/com/github/nkzawa/global/Global.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.github.nkzawa.global;
|
||||
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class Global {
|
||||
|
||||
private Global() {}
|
||||
|
||||
public static String encodeURIComponent(String str) {
|
||||
try {
|
||||
return URLEncoder.encode(str, "UTF-8")
|
||||
.replace("+", "%20")
|
||||
.replace("%21", "!")
|
||||
.replace("%27", "'")
|
||||
.replace("%28", "(")
|
||||
.replace("%29", ")")
|
||||
.replace("%7E", "~");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String decodeURIComponent(String str) {
|
||||
try {
|
||||
return URLDecoder.decode(str, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user