public void putNextEntry ( ZipEntry e ) throws IOException { ensureOpen ( ) ; if ( current != null ) { closeEntry ( ) ; // close previous entry } if ( e . time == - 1 ) { e . setTime ( System . currentTimeMillis ( ) ) ; } if ( e . method == - 1 ) { e . method = method ; // use default method } // store size, compressed size, and crc-32 in LOC header e . flag = 0 ; switch ( e . method ) { case DEFLATED : // store size, compressed size, and crc-32 in data descriptor // immediately following the compressed entry data if ( e . size == - 1 || e . csize == - 1 || e . crc == - 1 ) e . flag = 8 ; break ; case STORED : // compressed size, uncompressed size, and crc-32 must all be // set for entries using STORED compression method if ( e . size == - 1 ) { e . size = e . csize ; } else if ( e . csize == - 1 ) { e . csize = e . size ; } else if ( e . size != e . csize ) { throw new ZipException ( "STORED entry where compressed != uncompressed size" ) ; } if ( e . size == - 1 || e . crc == - 1 ) { throw new ZipException ( "STORED entry missing size, compressed size, or crc-32" ) ; } break ; default : throw new ZipException ( "unsupported compression method" ) ; } if ( ! names . add ( e . name ) ) { throw new ZipException ( "duplicate entry: " + e . name ) ; } if ( zc . isUTF8 ( ) ) e . flag |= EFS ; current = new XEntry ( e , written ) ; xentries . add ( current ) ; writeLOC ( current ) ; }
Begins writing a new ZIP file entry and positions the stream to the start of the entry data . Closes the current entry if still active . The default compression method will be used if no compression method was specified for the entry and the current time will be used if the entry has no set modification time .