简体   繁体   中英

Unzip a zip file in BlackBerry Java app

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

Do I have to use a third party library? Does anyone have some 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();
    }

Use ZipME for unzip the zip archive files in Java ME / Blackberry applications.

Look on 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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM