public static void copyFile(File fromFile,File toFile) throws IOException {
  FileInputStream fileInputStream=new FileInputStream(fromFile);
  FileOutputStream fileOutputStream=new FileOutputStream(toFile);
  int i;
  byte bytes[]=new byte[2048];
  while ((i=fileInputStream.read(bytes)) != -1) {
    fileOutputStream.write(bytes,0,i);
  }
  fileInputStream.close();
  fileOutputStream.close();
}

public static void copyFile ( File fromFile , File toFile ) throws IOException { FileInputStream fileInputStream = new FileInputStream ( fromFile ) ; FileOutputStream fileOutputStream = new FileOutputStream ( toFile ) ; int i ; byte bytes [ ] = new byte [ 2048 ] ; while ( ( i = fileInputStream . read ( bytes ) ) != - 1 ) { fileOutputStream . write ( bytes , 0 , i ) ; } fileInputStream . close ( ) ; fileOutputStream . close ( ) ; }
helper method to copy file to a new location
