private static void copyFiles(Manifest manifest,JarFile in,JarArchiveOutputStream out,long timestamp) throws IOException {
  final byte[] buffer=new byte[4096];
  int num;
  final Map<String,Attributes> entries=manifest.getEntries();
  final List<String> names=new ArrayList<>(entries.keySet());
  Collections.sort(names);
  for (  final String name : names) {
    final JarEntry inEntry=in.getJarEntry(name);
    if (inEntry.getMethod() == JarArchiveEntry.STORED) {
      out.putArchiveEntry(new JarArchiveEntry(inEntry));
    }
 else {
      final JarArchiveEntry je=new JarArchiveEntry(name);
      je.setTime(timestamp);
      out.putArchiveEntry(je);
    }
    final InputStream data=in.getInputStream(inEntry);
    while ((num=data.read(buffer)) > 0) {
      out.write(buffer,0,num);
    }
    out.flush();
    out.closeArchiveEntry();
  }
}

private static void copyFiles ( Manifest manifest , JarFile in , JarArchiveOutputStream out , long timestamp ) throws IOException { final byte [ ] buffer = new byte [ 4096 ] ; int num ; final Map < String , Attributes > entries = manifest . getEntries ( ) ; final List < String > names = new ArrayList < > ( entries . keySet ( ) ) ; Collections . sort ( names ) ; for ( final String name : names ) { final JarEntry inEntry = in . getJarEntry ( name ) ; if ( inEntry . getMethod ( ) == JarArchiveEntry . STORED ) { out . putArchiveEntry ( new JarArchiveEntry ( inEntry ) ) ; } else { final JarArchiveEntry je = new JarArchiveEntry ( name ) ; je . setTime ( timestamp ) ; out . putArchiveEntry ( je ) ; } final InputStream data = in . getInputStream ( inEntry ) ; while ( ( num = data . read ( buffer ) ) > 0 ) { out . write ( buffer , 0 , num ) ; } out . flush ( ) ; out . closeArchiveEntry ( ) ; } }
copy all the files in a manifest from input to output .
