public static void writeFile(File file,byte[] data){
  try {
    RandomAccessFile ra=new RandomAccessFile(file,"rw");
    ra.write(data);
    ra.setLength(data.length);
    ra.close();
  }
 catch (  IOException e) {
    throw new RuntimeException("Error writing to file " + file,e);
  }
}

public static void writeFile ( File file , byte [ ] data ) { try { RandomAccessFile ra = new RandomAccessFile ( file , "rw" ) ; ra . write ( data ) ; ra . setLength ( data . length ) ; ra . close ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "Error writing to file " + file , e ) ; } }
create or overwrite a file .
