我如何附加文件Java中的.tar归档文件? [英] How do I append files to a .tar archive in Java?

查看:199
本文介绍了我如何附加文件Java中的.tar归档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Java中创建一个tar归档。我有一个正在不断地被创建的文件,我想工作线程采取从队列这些文件的引用,将它们复制到归档。

I would like to create a tar archive in Java. I have files which are constantly being created and I'd like a worker thread to take a reference to those files from a queue and copy them into the archive.

我尝试使用Apache的COM pression库的TarArchiveOutputStream要做到这一点,但我不希望保留存档打开程序的整个持续时间(因为除非我完成归档,它可以成为破坏 - 所以我宁愿追加到它在批次),而我还没有找到要添加到他们的库中的现有tar归档(他们这样做有ChangeSetPerformer级的好办法,但它基本上只是创建一个新的焦油和需要复制旧的全部,这是不是为我好,性能明智的)。

I tried using Apache Compression library's TarArchiveOutputStream to do this, but I do not wish to keep the archive open for the entire duration of the program (since unless i finalize the archive, it can become corrupted - so i'd rather append to it in batches), and I haven't found a good way to append to an existing tar archive with their library (They do have the "ChangeSetPerformer" class, but it basically just creates a new tar and needs to copy the old one entirely, which isn't good for me, performance wise).

我还需要图书馆没有下限存档的大小(即4克左右是不够的),我宁愿避免实际COM preSS存档。

I also need the library to not have a low limit for the size of the archive (i.e. 4g or so is not enough), and i'd rather avoid having to actually compress the archive.

任何建议将是极大的AP preciated!
谢谢你。

Any suggestions would be greatly appreciated! thank you.

推荐答案

您焦油的限制跑这里:的 http://en.wikipedia.org/wiki/Tar_(file_format)#Random_access

You run here in a limitation of tar: http://en.wikipedia.org/wiki/Tar_(file_format)#Random_access

因为,这是很难添加或删除单个文件而不复制整个档案。

because of that it is hard to add or remove single files without copying the whole archive.

这篇关于我如何附加文件Java中的.tar归档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆