Shai! here is my contribution for a future zip/unzip class
import com.codename1.io.FileSystemStorage;
import com.codename1.io.Log;
import com.codename1.io.Storage;
import com.codename1.ui.Display;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import net.sf.zipme.ZipEntry;
import net.sf.zipme.ZipInputStream;
/**
*
* @author roman
*/
public class Unzip {
public Unzip(String zipName, String dirDest) {
InputStream is;
try {
is = Storage.getInstance().createInputStream(zipName);
ZipInputStream zipStream = new ZipInputStream(is);
ZipEntry entry;
// create a buffer to improve copy performance later.
byte[] buffer = new byte[2048];
while ((entry = zipStream.getNextEntry()) != null) {
String s = entry.getName();
// System.out.println(s);
// Once we get the entry from the stream, the stream is
// positioned read to read the raw data, and we keep
// reading until read returns 0 or less.
String outdir = FileSystemStorage.getInstance().getAppHomePath();
if (outdir.length() > 0)
{
outdir = outdir + "/" + dirDest;
}
String outpath = outdir + "/" + entry.getName();
OutputStream output = null;
try {
output = FileSystemStorage.getInstance().openOutputStream(outpath);
int len = 0;
while ((len = zipStream.read(buffer)) > 0) {
output.write(buffer, 0, len);
}
} finally {
// we must always close the output file
if (output != null) {
output.close();
}
}
}
} catch (IOException ex) {
Log.p(ex.getMessage(), 0);
}
}
/**
* Unzip from stream
* @param zipFile
* @param dirDest
*/
public Unzip(InputStream zipFile, String dirDest) {
InputStream is;
try {
is = zipFile;
ZipInputStream zipStream = new ZipInputStream(is);
ZipEntry entry;
// create a buffer to improve copy performance later.
byte[] buffer = new byte[2048];
while ((entry = zipStream.getNextEntry()) != null) {
String s = entry.getName();
String outdir = FileSystemStorage.getInstance().getAppHomePath();
if (outdir.length() > 0)
{
outdir = outdir + "/" + dirDest;
}
String outpath = outdir + "/" + entry.getName();
OutputStream output = null;
try {
output = FileSystemStorage.getInstance().openOutputStream(outpath);
int len = 0;
while ((len = zipStream.read(buffer)) > 0) {
output.write(buffer, 0, len);
}
} finally {
// we must always close the output file
if (output != null) {
output.close();
}
}
}
} catch (IOException ex) {
Log.p(ex.getMessage(), 0);