【求助】网址中有空格要用什么代替?
网上说用html转义字符代替,故改成这样,还是行不通。
这是部分代码,完整的代码测试过,在没有空格的地址是可以下载的。
第一次发帖求助,哪弄错了还请指教
class DownloadService implements Runnable{ public void run() { try { String temp=http://192.168.1.100:8080/mp3/What if she is an angel.mp3; String adress=mp3Address.replace(" ", " ");System.out.println(adress); InputStream is = downloader.getInputStreamFromUrl(adress); } } public InputStream getInputStreamFromUrl(String urlStr) throws MalformedURLException, IOException { URL url = new URL(urlStr); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); InputStream inputStream = urlConn.getInputStream(); return inputStream; }