2012-04-10 24 views
8

Tôi đang cố mở tệp ZIP trong JAVA.Tệp zip rất lớn (> 50GB) -> ZipException: tiêu đề CEN không hợp lệ

Đoạn code dưới đây hoạt động tốt, ngoại trừ với một số tác phẩm lớn trong trường hợp này tôi có được ngoại lệ sau đây:

Exception in thread "main" java.util.zip.ZipException: invalid CEN header (bad signature) 
at java.util.zip.ZipFile.open(Native Method) 
at java.util.zip.ZipFile.<init>(ZipFile.java:114) 
at java.util.zip.ZipFile.<init>(ZipFile.java:75) 

Có một lỗi được biết? Có thể do mức độ nén cao hơn không được hỗ trợ trong JAVA?

Lưu ý rằng tôi không thể sử dụng Winzip để giải nén tệp và gzip trong Linux đưa ra lỗi về độ dài dữ liệu (tệp không nén là khoảng 80 GB). Tôi đã phải sử dụng giải pháp sau đây để giải nén nó:

gunzip -S .zip <file.zip> file 

Bất kỳ ý tưởng nào sẽ rất hữu ích.

Code:

if (file.getExtension().equals("gz")) { 
    br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(name)))); 
} 
else if (file.getExtension().equals("zip")) { 
    ZipFile zipFile = new ZipFile(name); // <-------------------FAILS HERE 
    Enumeration<? extends ZipEntry> entries = zipFile.entries(); 
    while (entries.hasMoreElements()) { 
     ZipEntry zipEntry = entries.nextElement(); 
     System.out.println("ZIP File in the archive:" + zipEntry.getName()); 
     br = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry))); 
     break; 
    } 
} 
+1

lẽ Apache Commons nén có thể giúp đây? Việc triển khai zip tích hợp không phải là tốt nhất theo như tôi biết. – biziclop

+2

Có giới hạn kích thước trong triển khai zip mặc định. Bạn có thể tìm thấy [answer] (http://stackoverflow.com/a/6738811/1048330) hữu ích này. – tenorsax

Trả lời

Các vấn đề liên quan