code: public static void writeData(final long user, final List<Preference<Long, Long>> recommendations, final String path, final String fileName, final boolean append, final TemporalDataModelIF<Long, Long> model) {
          BufferedWriter out = null;
          try {
              File dir = null;
              if (path != null) {
                  dir = new File(path);
                  if (!dir.isDirectory()) {
                      if (!dir.mkdir() && (fileName != null)) {
                          System.out.println("Directory " + path + " could not be created");
                          return;
                      }
                  }
              }
              if ((path != null) && (fileName != null)) {
                  out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + "/" + fileName, append), "UTF-8"));
              }
              for (Preference<Long, Long> recItem : recommendations) {
                  if (out != null) {
                      out.write(user + "\t" + recItem.getItem()+ "\t" + recItem.getScore() + "\n");
                  }
                  if (model != null) {
                      model.addPreference(user, recItem.getItem(), recItem.getScore());
                  }
              }
              if (out != null) {
                  out.flush();
                  out.close();
              }
          } catch (IOException e) {
              System.out.println(e.getMessage());
  //            logger.error(e.getMessage());
          } finally {
              if (out != null) {
                  try {
                      out.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
docs: Write recommendations to file.
  
  @param user the user
  @param recommendations the recommendations
  @param path directory where fileName will be written (if not null)
  @param fileName name of the file, if null recommendations will not be
  printed
  @param append flag to decide if recommendations should be appended to
  file
  @param model if not null, recommendations will be saved here