在Java中,可以使用URLDecoder
类对编码字符串进行解码。
以下是一个示例:
import java.net.URLDecoder;
public class DecodeExample {
public static void main(String[] args) {
String encodedString = "Hello%20World%21"; // 编码的字符串
String decodedString = URLDecoder.decode(encodedString, "UTF-8"); // 解码字符串
System.out.println(decodedString); // 输出解码后的字符串
}
}
在上面的示例中,使用URLDecoder.decode
方法对编码字符串进行解码,第一个参数是要解码的字符串,第二个参数是字符编码(例如UTF-8)。解码后的字符串将被打印输出。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Java中如何对URL进行编码和解码