public static File createRandomFile(File folder,String name,final int length) throws IOException {
  File file=new File(folder,name);
  if (file.exists()) {
    file.delete();
  }
  try (BufferedWriter output=new BufferedWriter(new FileWriter(file))){
    output.write(RandomStringUtils.random(length));
  }
   return file;
}

public static File createRandomFile ( File folder , String name , final int length ) throws IOException { File file = new File ( folder , name ) ; if ( file . exists ( ) ) { file . delete ( ) ; } try ( BufferedWriter output = new BufferedWriter ( new FileWriter ( file ) ) ) { output . write ( RandomStringUtils . random ( length ) ) ; } return file ; }
creates file by specified name and length , the content of file is random string .
