感谢这个线程如何使用Java从Internet下载和保存文件? 我知道如何下载文件,现在我的问题是我需要在我正在下载的服务器上进行身份验证.它是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)
Run Code Online (Sandbox Code Playgroud)
谢谢,
java authentication download httpwebrequest basic-authentication