public class ImageTool {          //工具类@SuppressWarnings("finally")public static byte[] getUrlData(String path){ByteArrayOutputStream bos = null;try{URL url = new URL(path);bos = new ByteArrayOutputStream();byte data[] = new byte[1024];HttpURLConnection conn = (HttpURLConnection)url.openConnection();InputStream input = conn.getInputStream();int len = 0;while((len = input.read(data))!= -1){bos.write(data, 0, len);}System.out.println("正在读取");}catch(Exception e){e.printStackTrace();}finally{if(bos!=null){try {bos.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}System.out.println("读取完毕");return bos.toByteArray();}}}



byte data [] = ImageTool.getUrlData("http://www.num90.com/qqt/1.jpg");    //实现类Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);


更多相关文章

  1. android 之 读取本地json文件返回string
  2. Android巴士转发
  3. android截屏并将截图缩放
  4. Android中调用摄像头并实现对焦拍照
  5. 分享一个Android左右侧滑的效果实现 sliding layout
  6. Android实现google消息通知
  7. android如何用代码实现界面ui
  8. android实现双击事件的监听
  9. 浅谈Java中Collections.sort对List排序的两种方法

随机推荐

  1. 安装laravel框架
  2. 实战原生微信接入和消息回复
  3. react-redux源码不完全指北
  4. 婚恋网后台管理路由
  5. easywechat实现微信接入并不同消息回复+
  6. easywechat的使用
  7. 微信公众号接入与发送接收消息
  8. 婚恋网后台的资源路由 普通控制器和资源
  9. PDO预处理与会话控制
  10. vue_1