【问题标题】:Tomcat: WebService response as zip archive instead of fileTomcat:WebService 响应为 zip 存档而不是文件
【发布时间】:2011-01-24 13:57:05
【问题描述】:

我希望网络服务以 zip 文件的形式做出响应。

通常没有什么难做的。但我想知道一件事: 即使文件非常大(100Mb - 500Mb),我可以在不保存到硬盘的情况下压缩文件吗?

现在我正在使用这个不错的技巧。我想用压缩功能扩展它而不在文件系统上创建新文件。

public class TempFileInputStream extends FileInputStream {

    private File file;

    public TempFileInputStream(File file) throws FileNotFoundException {
        super(file); // TO WANT: to pass here already zipped stream
        this.file = file;
    }

    @Override
    public void close() throws IOException {
        super.close();
        if (!file.delete()) {
            // baad
        } else {
            // good 
        }
    }
}

如果可以,那么更好/最佳的方法是什么?

感谢您的帮助!

【问题讨论】:

    标签: java tomcat zip


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-05
      相关资源
      最近更新 更多