Android では、いくつかのファイルを Zip アーカイブにパックしたいと考えています (を使用java.util.zip
)。しかし、出力ファイルのサイズには制限があります。それらを複数の固定サイズのファイルにパックする可能性はありますか?
2 に答える
次のようにするとどうなりますか。
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
.
最近、似たようなことをする必要がありました (Android ではありませんが、原則は同じです)。一連の固定サイズの「チャンク」に書き込むMultiFileOutputStreamと、チャンクを再び 1 つのストリームに再構築する対応する入力ストリームを考え出しました。マルチファイル ストリームの上にcommons-compress TAR ストリームを重ねますが、zip ストリームを同様に使用することもできます。