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();
}
}
}
本地读取图片转化为byte[]
最新推荐文章于 2024-08-03 08:40:05 发布