Q: Java can't unzip files inside apache web server directory - java.util.zip.ZipError: zip END header not found I am having weird issues with a java application unzipping files on an apache server.
I have an apache server in which some other applications uploads zip files.
e.g. the directory is /var/www/html/fles
When I now start my java program to unzip the files it always fails with the following exception below.
I also checked the contentType using Files.probeContentType(file) and astonishingly it returns text/plain instead of application/zip 
I then tested the code in another directory, e.g. the home dir and there it works flawlessly.
So it seems it has something do do with the apache config, but I already checked and disabled gzip compression for zip files: 
I have no clue what else I have to do
My deflate.conf:
<IfModule mod_deflate.c>
        <IfModule mod_filter.c>
                # these are known to be safe with MSIE 6
                AddOutputFilterByType DEFLATE text/html text/plain text/xml

                # everything else may cause problems with MSIE 6
                AddOutputFilterByType DEFLATE text/css
                AddOutputFilterByType DEFLATE application/x-javascript application/javascript $
                AddOutputFilterByType DEFLATE application/rss+xml
                AddOutputFilterByType DEFLATE application/xml

                SetOutputFilter DEFLATE
                SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png|zip)$" no-gzip
        </IfModule>
</IfModule>

The java code for creating a zip Filesystem: The excpetions already happens at the creation of the filesystem:
 private static FileSystem createZipFileSystem(Path zipFilename,
            boolean create)
            throws IOException {
        // convert the filename to a URI

        final URI uri = URI.create("jar:file:" + zipFilename.toUri().getPath());

        final Map<String, String> env = new HashMap<>();
        if (create) {
            env.put("create", "true");
        }
        return FileSystems.newFileSystem(uri, env);
    }

The exception I get:
  java.util.zip.ZipError: zip END header not found
            at com.sun.nio.zipfs.ZipFileSystem.zerror(ZipFileSystem.java:1605)
            at com.sun.nio.zipfs.ZipFileSystem.findEND(ZipFileSystem.java:1021)
            at com.sun.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1030)
            at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:130)
            at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:117)
            at java.nio.file.FileSystems.newFileSystem(FileSystems.java:326)
            at java.nio.file.FileSystems.newFileSystem(FileSystems.java:276)


A: I found the problem is not about the unzipping, but after a while I realized that I run into the issue as described here:
Java 7 Watch Service ENTRY_CREATE triggered before file is written
