我将如何将 BufferedImage 直接保存到 zip 文件中。
这是我当前用于将 BufferedImage 保存到 zip 文件的代码,但我不知道如何将 BufferedImage 转换为 InputStream 以便可以将其保存到 zip 文件中。
如果可能的话,我需要直接从 RAM 中保存 BufferedImage 而不先将其保存到 HDD
byte[] buffer = new byte[1024];
try
{
    FileOutputStream outputStream = new FileOutputStream(PathName + imageData.getFileNumber() + ".zip");
    ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
    ZipEntry imageZipOutput = new ZipEntry(imageData.getFileNumber() + ".png");
    zipOutputStream.putNextEntry(imageZipOutput);
    //the BufferedImage is stored in imageData.getImage();
    //how would I parse the BufferedImage to the InputStream below without saving the png first but straight from RAM
    InputStream in = new InputStream();
    int len;
    while ((len = in.read(buffer)) > 0)
    {
        zipOutputStream.write(buffer, 0, len);
    }
    in.close();
    zipOutputStream.closeEntry();
    zipOutputStream.close();
}