远程url文件地址转成byte
2016-03-16 13:42
495 查看
public static byte[] urlTobyte(String url) throws MalformedURLException { URL ur = new URL(url); BufferedInputStream in = null; ByteArrayOutputStream out = null; try { in = new BufferedInputStream(ur.openStream()); out = new ByteArrayOutputStream(1024); byte[] temp = new byte[1024]; int size = 0; while ((size = in.read(temp)) != -1) { out.write(temp, 0, size); } } catch (Exception e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } byte[] content = out.toByteArray(); return content; }
相关文章推荐
- C++的深拷贝与浅拷贝
- Unity中携程与线程指南
- mybatis Association标签 分两次sql查询时,参数传递问题
- centos 命令集合
- SYN4104型 数字网同步时钟
- SSM框架——使用MyBatis Generator自动创建代码
- 2016年学习计划
- import github project As Android Project In Eclipse
- bug修复-fragment setArguments报错
- ubuntu与centos安装软件的不同点总结
- JAVA_棱形(实心) + 蝴蝶结(实心)打印
- Sicily 1099 Packing Passengers
- 单例模式
- 55页Pacific Trails Resort案例分析
- python获取及时可用国外高匿名代理
- ElasticSearch
- 在windows上新建一个ftp服务器
- iOS开发 图片上传
- http1.0 和 http1.1 区别
- 《Linux内核设计与实现》读书笔记 - 目录 (完结)【转】