2

Android では、いくつかのファイルを Zip アーカイブにパックしたいと考えています (を使用java.util.zip)。しかし、出力ファイルのサイズには制限があります。それらを複数の固定サイズのファイルにパックする可能性はありますか?

4

2 に答える 2

0

次のようにするとどうなりますか。

Let's say, that you know (aproximately) the compress ratio of your files... You take first few files that doesn't exceed for example 2MB. If compress ratio is 50% you'll get 1MB file at the end. You repeat the process untill you zip all the files...

Regarding one big text file I would suggest this. Read the file and write it into two/three/four seperate files. You can do this with FileInputStream and FileOutputStream... ZIP each of parts.. After unziping, glue them together again with help of File(Input/Output)Stream.

于 2012-09-05T10:27:28.133 に答える
0

最近、似たようなことをする必要がありました (Android ではありませんが、原則は同じです)。一連の固定サイズの「チャンク」に書き込むMultiFileOutputStreamと、チャンクを再び 1 つのストリームに再構築する対応する入力ストリームを考え出しました。マルチファイル ストリームの上にcommons-compress TAR ストリームを重ねますが、zip ストリームを同様に使用することもできます。

于 2012-09-05T11:27:09.377 に答える