Skip to content

Getting “ invalid distances set” during unzipping if zip file was copied with FileUtils.copyFile() before

I get the exception invalid distances set
    at java.base/
    at java.base/
    at java.base/

when I want to unzip a file that I have copied before with

FileUtils.copyFile(File srcFile, File destFile)


If I don’t copy the file and use the original zip file, the unzipping works just fine.

I have also used a different file-copy API from google guava. But the error is the same when I want to unzip the file.

The file I want to copy and unzip is a large file: its an adopt-open-jdk zip file.

I don’t think it is an error in the unzipping logic. It is more related to what the copy does to the file such that it can’t be unzipped correctly.

I use the following sample code for unzipping:

Edit: the copied file does not become corrupt. The file size is identical with the original and I can open the copied zip with 7zip with no errors. Content is complete.



I found the error myself. The previous maven build process copied the zip-file incorrectly and incompletely into a target jar file instead of inside the target folder directly. After that, I was accessing that file via classloader and the fileutils.copy copied an already incorrectly stored zip.

My bad, I did compare the wrong files when writing they were identical.

User contributions licensed under: CC BY-SA
10 People found this is helpful