首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

当地读取图片转化为byte[]

2012-07-25 
本地读取图片转化为byte[]public void read(){String imagePath d:/lxp.bmpbyte[] tmp new byte[40

本地读取图片转化为byte[]

public void read(){String imagePath = "d:/lxp.bmp";byte[] tmp = new byte[4096]; ByteArrayOutputStream buffer = new ByteArrayOutputStream();InputStream in = null;try {in = new FileInputStream(imagePath);int len;while((len = in.read(tmp)) != -1){buffer.write(tmp,0,len);}imageData = buffer.toByteArray();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}finally{try {if(in != null)in.close();} catch (IOException e) {e.printStackTrace();}}}

热点排行