private static void copyFile ( File file , InputStream is , String mode ) throws IOException , InterruptedException { final String abspath = file . getAbsolutePath ( ) ; final FileOutputStream out = new FileOutputStream ( file ) ; byte buf [ ] = new byte [ 1024 ] ; int len ; while ( ( len = is . read ( buf ) ) > 0 ) { out . write ( buf , 0 , len ) ; } out . close ( ) ; is . close ( ) ; Runtime . getRuntime ( ) . exec ( "chmod " + mode + " " + abspath ) . waitFor ( ) ; }
copy file to destination