[英]Connection to https://mail.google.com refused, apache httpclient
I can download files like that: 我可以像这样下载文件:
If url is , for instance http:/b.net/Doc1.pdf it downloads very well, but if it is, for example "https:/mail.google.com/mail/u/0/?ui=2&ik=e3036d4c0a&view=att&th=13c8b8af8687d931&attid=0.1&disp=safe&realattid=f_hckh9zby0&zw" (gmail attached pdf), it cant download. 如果url为,例如http:/b.net/Doc1.pdf,则下载得很好,但是如果是url,例如为“ https:/mail.google.com/mail/u/0/?ui = 2&ik = e3036d4c0a&view = att&th = 13c8b8af8687d931&attid = 0.1&disp = safe&realattid = f_hckh9zby0&zw“(gmail pdf pdf),无法下载。 I have that error
我有那个错误
Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to https://mail.google.com refused 线程“主” org.apache.http.conn.HttpHostConnectException中的异常:拒绝连接到https://mail.google.com
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
long len = entity.getContentLength();
InputStream inputStream = entity.getContent();
File temp = File.createTempFile("Google", ".pdf", new File("/"));
OutputStream output = new FileOutputStream(temp);
byte[] buffer = new byte[1024];
int n = 0;
while ((n = inputStream.read(buffer)) != -1){
output.write(buffer, 0, n);
}
output.close();
}
org.apache.http.conn.HttpHostConnectException: Connection to https://mail.google.com refused org.apache.http.conn.HttpHostConnectException:拒绝连接到https://mail.google.com
I've solved this like that " http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientExecuteProxy.java " 我已经像这样解决了这个问题:“ http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientExecuteProxy.java ”
I had proxy problems; 我有代理问题;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.