public void addFile ( File file ) throws IOException { if ( ! file . exists ( ) ) { throw new IllegalArgumentException ( String . format ( "File |%s| does not exist." , file ) ) ; } if ( file . isDirectory ( ) ) { throw new IllegalArgumentException ( String . format ( "File |%s| is a directory." , file ) ) ; } addFileEntry ( file . getPath ( ) , new FileInputStream ( file ) ) ; }
Inject file content into archive using file relative path as archive entry name . File to add is relative to a common base directory . All files from this archive should be part of that base directory hierarchy ; it is user code responsibility to enforce this constrain .