@ SuppressWarnings ( { "JavaDoc" } ) protected boolean createEmptyZip ( File zipFile ) throws ArchiverException { // In this case using java.util.zip will not work // because it does not permit a zero-entry archive. // Must create it manually. getLogger ( ) . info ( "Note: creating empty " + archiveType + " archive " + zipFile ) ; OutputStream os = null ; try { os = new FileOutputStream ( zipFile ) ; // Cf. PKZIP specification. byte [ ] empty = new byte [ 22 ] ; empty [ 0 ] = 80 ; // P empty [ 1 ] = 75 ; // K empty [ 2 ] = 5 ; empty [ 3 ] = 6 ; // remainder zeros os . write ( empty ) ; } catch ( IOException ioe ) { throw new ArchiverException ( "Could not create empty ZIP archive " + "(" + ioe . getMessage ( ) + ")" , ioe ) ; } finally { IOUtil . close ( os ) ; } return true ; }
Create an empty zip file