Java не распаковывает большие файлы Android ( error in opening zip file )
Всем доброго дня, возникла необходимость распаковки файлов, создан некий код, который работает ( ну почти ), но не хочет распаковывать файлы больше 120мб.
Код самого депаковщика:
try {
ZipFile zipfile = new ZipFile(archive);
for (Enumeration e = zipfile.entries();
e.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) e.nextElement();
msg = new Message();
msg.what = 0;
msg.obj = "Распаковка: " + entry.getName();
myHandler.sendMessage(msg);
unzipEntry(zipfile, entry, outputDir);
}
} catch (Exception e) {
log("Error while extracting file " + archive);
log("Error is: " + e.getMessage());
}
Полный код класса:
public class UnZip implements Runnable {
File archive;
String outputDir;
public UnZip(File ziparchive, String directory) {
archive = ziparchive;
outputDir = directory;
}
public void log(String log) {
Log.v("unzip", log);
}
public void run() {
Message msg;
try {
ZipFile zipfile = new ZipFile(archive);
for (Enumeration e = zipfile.entries();
e.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) e.nextElement();
msg = new Message();
msg.what = 0;
msg.obj = "Распаковка: " + entry.getName();
myHandler.sendMessage(msg);
unzipEntry(zipfile, entry, outputDir);
}
} catch (Exception e) {
log("Error while extracting file " + archive);
log("Error is: " + e.getMessage());
}
msg = new Message();
msg.what = 1;
myHandler.sendMessage(msg);
}
public void streamCopy(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[32 * 1024]; // play with sizes..
int readCount;
while ((readCount = in.read(buffer)) != -1) {
out.write(buffer, 0, readCount);
}
}
public void unzipArchive(File archive, String outputDir) {
try {
ZipFile zipfile = new ZipFile(archive);
for (Enumeration e = zipfile.entries();
e.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) e.nextElement();
unzipEntry(zipfile, entry, outputDir);
}
} catch (Exception e) {
log("Error while extracting file " + archive);
log("Error is: " + e.getMessage());
}
}
private void unzipEntry(ZipFile zipfile, ZipEntry entry, String outputDir) throws IOException
{
if (entry.isDirectory()) {
createDir(new File(outputDir, entry.getName()));
return;
}
File outputFile = new File(outputDir, entry.getName());
if (!outputFile.getParentFile().exists()) {
createDir(outputFile.getParentFile());
}
log("Extracting: " + entry);
BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry));
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
try {
//streamCopy(inputStream,outputStream);
try {
IOUtils.copy(inputStream, outputStream);
//streamCopy(inputStream, outputStream);
}
catch (IOException e) {
log("Error is: " + e.getMessage());
}
} finally {
outputStream.close();
inputStream.close();
}
}
private void createDir(File dir) {
log("Creating dir " + dir.getName());
if (!dir.mkdirs())
throw new RuntimeException("Can not create dir " + dir);
}
}
Поиски по стеку, МСДН и другим местам ( гугл, документация и т.д ) ничего не дали. Сама ошибка: error in opening zip file
Прошу помочь и направить на решение данной проблемы ( заранее спасибо )