我试图以这种方式在非常慢的连接上下载文件:
java.net.URL url = new URL("https://X.X.X.X:8443/path/2f6b88cf2b70ee933197edfc9627a9bc/");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setConnectTimeout(240 * 1000);
connection.setReadTimeout(240 * 1000);
long start = System.currentTimeMillis();
Files.copy(connection.getInputStream(), new File("test.zip").toPath());
System.out.println("Time: "+((System.currentTimeMillis() - start) / 1000) + " sec.");
Run Code Online (Sandbox Code Playgroud)
我注意到由于某些原因(本机Windows套接字超时?)它总是在下载180秒后中断,没有任何例外.
在setConnectTimeout(...)或setReadTimeout(...)中设置的超时没有帮助.
我尝试使用wget下载该文件:
wget https://X.X.X.X:8443/path/2f6b88cf2b70ee933197edfc9627a9bc/ --no-check-certificate
--2015-09-07 14:36:12-- https://X.X.X.X:8443/path/2f6b88cf2b70ee933197edfc9627a9bc/
Connecting to X.X.X.X:8443... connected.
WARNING: The certificate of ‘X.X.X.X’ is not trusted.
WARNING: The certificate of ‘X.X.X.X’ hasn't got a known issuer.
The certificate's owner does not match hostname ‘X.X.X.X’
HTTP request sent, awaiting …Run Code Online (Sandbox Code Playgroud) 如何从我的Android类中检测到,我从代码中调用的号码正忙,呼叫被拒绝了?我尝试使用PhoneStateListener,但没有像'busy'这样的状态.任何帮助将不胜感激.