我想把applet端的图片编码,传送到servlet端,代码如下
//先写一个编码方法
  public static void writeJPEG(OutputStream out, BufferedImage image,
                                 int quality, IIOWriteProgressListener listener) throws
            IOException {
        ImageOutputStream ios = ImageIO.createImageOutputStream(out);
        Iterator it = ImageIO.getImageWritersBySuffix("jpg");
        if (it.hasNext()) {
            ImageWriter iw = (ImageWriter) it.next();
            ImageWriteParam iwp = iw.getDefaultWriteParam();
            iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
            iwp.setCompressionQuality((float) quality / 100f);
            iw.setOutput(ios);
            iw.addIIOWriteProgressListener(listener);
            iw.write(null, new IIOImage(image, null, null), iwp);
            iw.dispose();
            out.flush();
            out.close();
        }
    }
然后在applet端
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            writeJPEG(baos, bi1, 50, null);    //其中bi1是通过jPanel1取得的一个图象
            byte[] imageData = baos.toByteArray();
            String kk = new String(imageData);
            oos.writeUTF(kk);
在servlet端:
            String kk = ois.readUTF();
            byte [] imageData = kk.getBytes();
            ByteArrayInputStream bais = new ByteArrayInputStream(imageData);
            bi1 = ImageIO.read(bais);
            File file1 = new File("aa"+".jpg");
            ImageIO.write(bi1,"jpg",file1);结果在servlet端报错:
 java.lang.IllegalArgumentException:
 问题在这里:bi1为空。
 请问为什么会有这样的问题?应该如何解决呢