public static void createFile(String filePath,String header) throws IOException {
  File file=new File(filePath);
  if (!file.exists()) {
    file.createNewFile();
    FileWriter fileWriter=new FileWriter(filePath,true);
    fileWriter.write(header);
    fileWriter.close();
  }
}

public static void createFile ( String filePath , String header ) throws IOException { File file = new File ( filePath ) ; if ( ! file . exists ( ) ) { file . createNewFile ( ) ; FileWriter fileWriter = new FileWriter ( filePath , true ) ; fileWriter . write ( header ) ; fileWriter . close ( ) ; } }
checks whether the given file exists . if not , create such a file with a header written into it .
