//使用BASE64对图片文件数据进行解码操作
BASE64Decoder decoder = new sun.misc.BASE64Decoder();
//BASE64Decoder decoder = new BASE64Decoder();
//通过Base64解密,将图片数据解密成字节数组
byte[] bytes = decoder.decodeBuffer(ci.getImageData());
//构造字节数组输入流
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
//读取输入流的数据
BufferedImage bi = ImageIO.read(bais);
//将数据信息写进图片文件中
ImageIO.write(bi, "jpg", f);// 不管输出什么格式图片,此处不需改动
bais.close();
---------------------------------------------------------------------------
每当读取到ImageIO.read(bais);这个的时候,就会报异常,求大神呢指点
javax.imageio.IIOException: Bogus marker length
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1137)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:948)
at javax.imageio.ImageIO.read(ImageIO.java:1422)
at javax.imageio.ImageIO.read(ImageIO.java:1326)
at cn.chuxin.ebussiness.web.proposal.vehicle.PhotoEvidenceAction.base64SaveFile(PhotoEvidenceAction.java:339)
at cn.chuxin.ebussiness.web.proposal.vehicle.PhotoEvidenceAction.havePhotoToReport(PhotoEvidenceAction.java:304)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)