Android Question compressing list of files into a single file?

leitor79

Active Member
Licensed User
Longtime User
Hi!

Can multiple files be compressed into one gzip? How can I do it? I've tried several things, for example:

B4X:
Dim compress As CompressedStreams
.
.
.
out1=File.OpenOutput("",sFile,False)
out = File.Openoutput("", sc, True)
out=compress.WrapoutputStream(out1,"gzip")
WriteStringToStream(out, s)

With that I get 0 byte file.

I've also tried OpenInput for the file to compress (it has more sense to me since I'm not writing there) but I got errors (wrapinputstream returns an inputstream, thing I don't get it because I need an outputstream to write the file, right?)

Thank you!


PS: gzip or any format would do it.
 

leitor79

Active Member
Licensed User
Longtime User
Hi, Erel,

Thank you very much for your answer.

That function is the one on the documentation's example:

B4X:
Sub WriteStringToStream(Out As OutputStream, s As String)
    Dim t As TextWriter
    t.Initialize(Out)
    t.Write(s)
    t.Close 'Closes the internal stream as well
End Sub

I'll take a look at the archiver class.

Regards!
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi,

I've solved it with the Archiver library.

Arc.ZipFiles receives a list of files and put them into a single file.

Thank you for your suggestion!
 
Upvote 0
Top