HttpURLConnection无法打开含有中文的链接
方法:使用 URLEncoder
URLEncoder.encode(str, “utf-8”);
filepath = “http://localhost/movie/爱的发声练习.srt”
String srtname = filepath.substring(filepath.lastIndexOf(“/”) + 1);
filepath = filepath.substring(0,filepath.lastIndexOf(“/”))+
“/”+URLEncoder.encode(srtname,”utf-8”);
URL url = new URL(filepath);
HttpURLConnection conn = (HttpURLConnection) url
.openConnection();
一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!
二、互相尊重,对自己的言论和行为负责。