1
虽然转换InputStream
到BufferedImage
我得到下面的错误错误意外结束
byte[] imgBytes = decoder.decode(encodedStr);
这条线被执行细并生成字节数组正确
InputStream in = new ByteArrayInputStream(imgBytes);
BufferedImage bImageFromConvert = ImageIO.read(in);
这条线是给出错误,因为它无法正确读取InputStream
Below is the error
javax.imageio.IIOException: Error reading PNG image data
at com.sun.imageio.plugins.png.PNGImageReader.readImage(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at DecodeSignatureFile.generateImage(DecodeSignatureFile.java:252)
at DecodeSignatureFile.getContents(DecodeSignatureFile.java:176)
at DecodeSignatureFile.process(DecodeSignatureFile.java:322)
at DecodeSignatureFile.main(DecodeSignatureFile.java:334)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readFully(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.decodePass(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.decodeImage(Unknown Source)
... 8 more
是否有可能您的解码方法错误或** encodedStr **损坏? – 2013-04-30 08:49:23
什么是'解码器'?你在这里给我们提供了很少的信息。 – 2013-04-30 08:51:41