我在内存中生成了许多BufferedImages,我想将它们压缩成一个zip文件,然后再将其作为电子邮件附件发送.如何在不从磁盘读取文件的情况下将文件保存到zip文件中.
有没有办法在不创建临时文件的情况下压缩这些文件?
由于创建了数千个文件,因此写入磁盘非常耗时.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cccprog;
import java.awt.Component;
import java.awt.Panel;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
/**
*
* @author Z
*/
public class N {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 10; i++) {
JFrame jf = new JFrame();
Panel a = new Panel();
JRadioButton birdButton …Run Code Online (Sandbox Code Playgroud) java ×1