Tag: malformedurlexception

java.net.MalformedURLException:基于使用URLEncoder修改的字符串,URL上没有协议

所以我试图在URL中使用这个String: – http://site-test.collercapital.com/Meetings/IC/DownloadDocument?meetingId=c21c905c-8359-4bd6-b864-844709e05754&itemId=a4b724d1-282e-4b36-9d16-d619a807ba67&file=\\s604132shvw140\Test-Documents\c21c905c-8359-4bd6-b864-844709e05754_attachments\7e89c3cb-ce53-4a04-a9ee-1a584e157987\myDoc.pdf 在此代码中: – String fileToDownloadLocation = //The above string URL fileToDownload = new URL(fileToDownloadLocation); HttpGet httpget = new HttpGet(fileToDownload.toURI()); 但在这一点上我得到错误: – java.net.URISyntaxException: Illegal character in query at index 169:Blahblahblah 我通过一些谷歌搜索意识到这是由于URL中的字符(猜测&),所以我添加了一些代码,所以它现在看起来像这样: – String fileToDownloadLocation = //The above string fileToDownloadLocation = URLEncoder.encode(fileToDownloadLocation, “UTF-8”); URL fileToDownload = new URL(fileToDownloadLocation); HttpGet httpget = new HttpGet(fileToDownload.toURI()); 但是,当我尝试运行它时,当我尝试创建URL时出现错误,然后错误如下: – […]

为什么java的URL类不能识别某些协议?

URL u =新URL(“telnet://route-server.exodus.net”); 这条线正在产生: java.net.MalformedURLException:未知协议:telnet 我遇到与以“news://”开头的其他url类似的问题 这些是从ODP中提取的URL,所以我不明白为什么会出现这样的例外情况。