String code = "D:/%e5%ad%a6%e6%b5%b7/My%20Course/%e8%ae%a1%e7%ae%97%e4%b8%8e%e8%bd%af%e4%bb%b6%e5%b7%a5%e7%a8%8b/Java%20workspace/my Project/bin/";
try{
String src=URLDecoder.decode(code,"UTF-8");//註意編碼和輸入時壹致
System.out.print(src);
}catch (UnsupportedEncodingException e){
e.printStackTrace();
}
======
顯示:
D:/學海/My Course/計算與軟件工程/Java workspace/my Project/bin/
方法2:URI有自己的getPath方法,直接返回的就是解碼後的路徑
比如System.out.print(url.getPath());