public static int copyFile ( String from , String to ) { InputStream inStream = null ; FileOutputStream fs = null ; try { int bytesum = 0 ; int byteread ; File oldfile = new File ( from ) ; if ( oldfile . exists ( ) ) { inStream = new FileInputStream ( from ) ; fs = new FileOutputStream ( to ) ; byte [ ] buffer = new byte [ 1444 ] ; while ( ( byteread = inStream . read ( buffer ) ) != - 1 ) { bytesum += byteread ; fs . write ( buffer , 0 , byteread ) ; } } return bytesum ; } catch ( Exception e ) { return 0 ; } finally { Util . ensureClosed ( inStream ) ; Util . ensureClosed ( fs ) ; } }
This function copies file from one location to another