httpclient

 public class Download {
public static void main(String[] args) throws ClientProtocolException, IOException {
String url = "http://1251214202.vod2.myqcloud.com/8f3139d3vodgzp1251214202/c9bff9c47447398155998582539/5nFpW8vzdYAA.mp3";
CloseableHttpClient client = HttpClients.createDefault();
HttpGet get = new HttpGet(url);
CloseableHttpResponse response = client.execute(get);
if(response.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = response.getEntity();
// System.out.println(entity.getContentLength());
IOUtils.write(IOUtils.readFully(entity.getContent(),(int)entity.getContentLength()),new FileOutputStream("f:/枯叶双子.mp3"));
}
response.close();
get.abort();
client.close();
}
}

htmlunit

 public class Download {
public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient client = new WebClient(BrowserVersion.CHROME);
String url = "http://1251214202.vod2.myqcloud.com/8f3139d3vodgzp1251214202/c9bff9c47447398155998582539/5nFpW8vzdYAA.mp3";
Page page = client.getPage(url);
InputStream contentAsStream = page.getWebResponse().getContentAsStream();
IOUtils.write(IOUtils.readFully(contentAsStream,(int)page.getWebResponse().getContentLength()),new FileOutputStream("f:/枯叶双子111.mp3"));
client.close();
}
}

最新文章

  1. 关于seajs模块化的搭建
  2. mysql connector 和 sqlserver ado.net 的区别
  3. web一周
  4. 转来的。。。 关于return 的一些事情
  5. 领域模型中的实体类分为四种类型:VO、DTO、DO、PO
  6. QT 按钮(4种样式)
  7. 使用ambari搭建Hadoop平台
  8. Spark源码的编译过程详细解读(各版本)
  9. Csharp 简单操作Word模板文件
  10. 解决Sqlite UTF-8中文数据格式在DOS窗口下中文乱码
  11. node.js中favicon.ico请求两次问题
  12. 《C++ 标准库》读书笔记 - 第二章 Introduction to C++ and the Standard Library
  13. MySql基础笔记(二)Mysql语句优化---索引
  14. c语言模拟c++的继承和多态
  15. Team Foundation Server 2013 KEY(密钥)
  16. Iframe高度自适应(兼容IE/Firefox、同域/跨域)
  17. java 泛型详解-绝对是对泛型方法讲解
  18. 20155339《java程序设计》第十二周课堂实践总结
  19. 《Java核心技术》 -- 读书笔记 ② - 类 | 对象 | 接口
  20. PHP系统学习1

热门文章

  1. JQuery EasyUI Combobox 实现省市二级联动菜单
  2. Maven学习总结(16)——深入理解maven生命周期和插件
  3. 老李的菜园 mysql 自定义函数
  4. 去哪网实习总结:用到的easyui组件总结(JavaWeb)
  5. 2.CCGridAction(3D效果),3D反转特效,凸透镜特效,液体特效,3D翻页特效,水波纹特效,3D晃动的特效,扭曲旋转特效,波动特效,3D波动特效
  6. ZOJ List the Books 水~
  7. php实现判断树的子结构
  8. Ditto —— windows 剪贴板增强小工具(复制粘贴多条记录)
  9. python 升级pip
  10. ASP.Net WebAPI HttpDelete/PUT方法运行或发布到生产服务器上后出现405(Method Not Allowed)错误的解决办法