code: public static File saveFile(String name, String data) {
          if (name == null) {
              name = "";
          }
          String fullyQualifiedName = name;
  
          /**
           * if filename is not absolute use current path as base dir
           */
          if (!new File(fullyQualifiedName).isAbsolute()) {
              fullyQualifiedName = Paths.get("").toAbsolutePath().toString() + "/" + name;
          }
          try {
              //create subdirs (if there any)
              if (fullyQualifiedName.contains("/")) {
                  File f = new File(fullyQualifiedName.substring(0, fullyQualifiedName.lastIndexOf("/")));
                  f.mkdirs();
              }
              File file = new File(fullyQualifiedName);
              file.createNewFile();
              FileUtils.write(file, data, "UTF-8");
              log.info("Wrote: " + file.getAbsolutePath());
              return file;
          } catch (IOException e) {
              log.log(Level.SEVERE, "Could not create file " + name, e);
              return null;
          }
      }
docs: Saves a file into filesystem. Note that name can be saved as absolute (if it has a leading slash) or relative to current path.
  EX: /target/name.adoc will save the file into
  
  @param name file name
  @param data file content
  @return