Atitit httpclient4.0 get big file down
目录
1.1. /webdavclient/src/com/attilax/net/HttpClientUtil4_0_1.java 1
1.2. 默认下在比较慢,185M很长时间 ,需要关闭logbac日志 ,默认debug级别 2
[if !supportLists]1.1. [endif]/webdavclient/src/com/attilax/net/HttpClientUtil4_0_1.java
public void httpget(String url,String outputstream1File) throws FileNotFoundException
{
httpget(url,new FileOutputStream(new File(outputstream1File)));
}
public void httpget(String url,OutputStream outputstream1) {
HttpClient httpCilent = new DefaultHttpClient(); // Creates
// CloseableHttpClient
// instance
// with
// default
// configuration.
HttpGet httpGet = new HttpGet(url);
// httpCilent.execute(httpGet);
String srtResult = "";
HttpResponse httpResponse;
try {
httpResponse = httpCilent.execute(httpGet);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
httpResponse.getEntity().writeTo(outputstream1);
// srtResult = EntityUtils.toString(httpResponse.getEntity());
// return srtResult;
} else if (httpResponse.getStatusLine().getStatusCode() == 400) {
throw new RuntimeException("httpResponse.getStatusLine().getStatusCode() == 400");
} else if (httpResponse.getStatusLine().getStatusCode() == 500) {
throw new RuntimeException("httpResponse.getStatusLine().getStatusCode() == 500");
}
} catch (ParseException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
} // 鑾峰緱杩斿洖鐨勭粨鏋�
throw new RuntimeException(" err");
}
[if !supportLists]1.2. [endif]默认下在比较慢,185M很长时间 ,需要关闭logbac日志 ,默认debug级别
这就快乐,几秒搞定。。Down in some sec only.
/webdavclient/src/logback.xml
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
${LOG_HOME}/TestWeb.log.%d{yyyy-MM-dd}.log
30
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
10MB
网友评论