感谢这个线程How to download and save a file from Internet using Java? 我知道如何下载文件,现在我的问题是我需要在我正在下载的服务器上进行身份验证。它是一个 subversion 服务器的 http 接口。我需要查看哪个字段?
使用最后一条评论中发布的代码,我得到了这个异常:
java.io.IOException: Server returned HTTP response code: 401 for URL: http://myserver/systemc-2.0.1.tgz
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1305)
at java.net.URL.openStream(URL.java:1009)
at mypackage.Installer.installSystemc201(Installer.java:29)
at mypackage.Installer.main(Installer.java:38)
谢谢,