Unzip the zip file in your BlackBerry Java application

I am trying to write code that decompresses a zip archive and puts the output in another folder.

Do I need to use a third-party library? Does anyone have a code to get me started?

    ZipEntry dataZE;
    InputStream isData = getClass().getResourceAsStream("/" + dataName + ".zip");
    StringBuffer sbData = new StringBuffer();
    ZipInputStream dataZIS = new ZipInputStream(isData);
    FileConnection file =
        (FileConnection)Connector.open(
            "file:///SDCard/BlackBerry/documents/" + filename,
            Connector.READ_WRITE
        );
    if (!file.exists()) {                               
        file.mkdir();
    }                   

    while ((dataZE = dataZIS.getNextEntry()) != null) {
       out.write(dataZE );
       out.flash();
       dataZIS.closeEntry();
    }
+3
source share
1 answer

Use ZipME to decompress zip files in Java ME / Blackberry applications.

Have a look at this sample code:

ZipEntry dataZE;
InputStream isData = getClass().getResourceAsStream("/" + dataName + ".zip");
StringBuffer sbData = new StringBuffer();
ZipInputStream dataZIS = new ZipInputStream(isData);
while ((dataZE = dataZIS.getNextEntry()) != null) {
    // do something...
    dataZIS.closeEntry();
}
+7
source

Source: https://habr.com/ru/post/1781564/


All Articles