Example #1
0
  /** writes content of all results to a file */
  private String writeContentToFile(
      final String shortTitle,
      final File exportDirectory,
      final String charset,
      final QTIExportFormatter qef,
      final String fileNameSuffix) {
    // defining target filename
    final StringBuilder tf = new StringBuilder();
    tf.append(qef.getFileNamePrefix());
    tf.append(Formatter.makeStringFilesystemSave(shortTitle));
    tf.append("_");
    final DateFormat myformat = new SimpleDateFormat("yyyy-MM-dd__hh-mm-ss__SSS");
    final String timestamp = myformat.format(new Date());
    tf.append(timestamp);
    tf.append(fileNameSuffix);
    final String targetFileName = tf.toString();

    ExportUtil.writeContentToFile(targetFileName, qef.getReport(), exportDirectory, charset);

    return targetFileName;
  }
Example #2
0
  /**
   * some old testing
   *
   * @param args
   */
  public static void main(String[] args) {
    System.out.println("hello");
    // log.debug(linePrepend("asdfsdf. bla and. \n2.line\n3.third",">"));
    // log.debug(escape("bla<>and so on &&\nsecond line").toString());

    System.out.println(":" + StringEscapeUtils.escapeHtml("abcdef&<>") + ":");
    System.out.println(":" + StringEscapeUtils.escapeHtml("&#256;<ba>abcdef&<>") + ":");
    System.out.println(":" + StringEscapeUtils.escapeHtml("&#256;\n<ba>\nabcdef&<>") + ":");

    System.out.println(":" + Formatter.truncate("abcdef", 0) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", 2) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", 4) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", 6) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", 7) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", 8) + ":");

    System.out.println(":" + Formatter.truncate("abcdef", -2) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", -4) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", -6) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", -7) + ":");
    System.out.println(":" + Formatter.truncate("abcdef", -8) + ":");

    Locale loc = new Locale("de");
    Formatter f2 = new Formatter(loc);
    Date d = new Date();
    Calendar cal = Calendar.getInstance(loc);
    cal.setTime(d);
    cal.add(Calendar.HOUR_OF_DAY, 7);
    // so ists 16:36 nachmittags
    d = cal.getTime();
    System.out.println(f2.formatDate(d));
    System.out.println(f2.formatTime(d));
    System.out.println(f2.formatDateAndTime(d));

    System.out.println("Now make String filesystem save");
    // String ugly = "\"/asdf/?._||\"blaöäü";
    String ugly = "guido/\\:? .|*\"\"<><guidoöäü";
    System.out.println("input: " + ugly);
    System.out.println("output: " + Formatter.makeStringFilesystemSave(ugly));
  }