Unpacking the Zip Exception file: invalid record size (expected 193144, but received 193138 bytes)

I am trying to unzip a file (received from an FTP server):

ZipInputStream zis = new ZipInputStream( new FileInputStream(zipFile)); ZipEntry ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); File newFile = new File(outputFileName+outputFolder + File.separator + fileName); System.out.println("file unzip : " + newFile.getAbsoluteFile()); FileOutputStream fos = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.close(); sendFile = newFile; ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); System.out.println("Done"); 

I have only one text file in a .zip file. This code works fine on my local windows machine. However, when deploying to an ubuntu server, this excludes the following.

 java.util.zip.ZipException: invalid entry size (expected 193144 but got 193138 bytes) at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:386) at java.util.zip.ZipInputStream.read(ZipInputStream.java:156) at java.io.FilterInputStream.read(FilterInputStream.java:90) 

in com.empress.Xsync.updater.ClientConfiguration.unZipFile (ClientConfiguration.java:246)

I will manually unpack it ... fine. The .txt file size is 193144 bytes.

+7
source share
1 answer

It looks like your zip file was corrupted while transferring it to an Ubuntu machine. Try unzipping the same file from the command line on an Ubuntu machine to see if it reports problems.

If I made a random assumption, it would be that you transferred the ZIP file via FTP and used the "ascii" mode instead of the "binary" mode. (FTP could convert '\r\n' to '\n' six times ...)

+9
source

All Articles