List of usage examples for org.apache.commons.io.output FileWriterWithEncoding append
public Writer append(CharSequence csq) throws IOException
From source file:de.saly.json.jsr353.benchmark.data.CreateJsonTestFiles.java
private static File createBigStack(final String path, final int count, final Charset charset) throws Exception { if (count < 0 || path == null || path.length() == 0) { throw new IllegalArgumentException(); }//from www. j a v a2s. c o m final File json = new File( path + "/" + "generated_benchmark_test_file_bigstack_" + charset.name() + "_" + count + ".json"); if (json.exists()) { System.out.println("File already exists: " + json.getAbsolutePath()); return json; } final FileWriterWithEncoding sb = new FileWriterWithEncoding(json, charset); for (int i = 0; i < count; i++) { sb.append("{\"key\":"); sb.append("[true" + (i == count - 1 ? "" : ",")); } for (int i = 0; i < count; i++) { sb.append("]"); sb.append("}"); } sb.close(); return json; }
From source file:de.saly.json.jsr353.benchmark.data.CreateJsonTestFiles.java
private static File create(final String path, final int count, final Charset charset) throws Exception { if (count < 0 || path == null || path.length() == 0) { throw new IllegalArgumentException(); }//w w w. j a va2 s. c o m final File json = new File( path + "/" + "generated_benchmark_test_file_" + charset.name() + "_" + count + ".json"); if (json.exists()) { System.out.println("File already exists: " + json.getAbsolutePath()); return json; } final FileWriterWithEncoding sb = new FileWriterWithEncoding(json, charset); sb.append("{\n"); for (int i = 0; i < count; i++) { sb.append("\t\"special-" + i + "\":" + "\"" + "\\\\f\\n\\r\\t\\u6532\uDC00\uD800" + "\",\n"); sb.append("\t\"unicode-\\u0000- " + i + "\":\"\\u5656\uDC00\uD800\",\n"); sb.append("\t\"\u6532bigdecimal" + i + "\":7817265.00000111,\n"); sb.append("\t\"bigdecimal-2-" + i + "\":127655512123456.761009E-123,\n"); sb.append("\t\"string-" + i + "\":\"lorem ipsum, ????????????.-,<!$%&/()9876543XXddddJJJJJJhhhhhhhh\uDC00\uD800\",\n"); sb.append("\t\t\t\t\"int" + i + "\":[1,-4543,112,0,1,10,100,87,34112, true, false, null],\n"); sb.append("\t\"\u6532ints" + i + "\":0,\n"); sb.append("\t\"\u6532false" + i + "\":false,\n"); sb.append("\t\"\u6532nil" + i + "\":false,\n"); sb.append("\t\"\u6532n" + i + "\": null ,\n"); sb.append("\t\"obj" + i + "\":\n"); sb.append("\t\t{\n"); sb.append("\t\t\t\"special-" + i + "\":" + "\"" + "\\\\f\\n\\r\\t\\u6532" + "\",\n"); sb.append("\t\t\t\"unicode-\\u0000- " + i + "\":\"\\u5656\",\n"); sb.append(" \"bigdecimal" + i + "\":7817265.00000111,\n"); sb.append("\t\t\t\"bigdecimal-2-" + i + "\":127655512123456.761009E-123,\n"); sb.append("\t\t\t\"string-" + i + "\":\"lorem ipsum, ????????????.-,<!$%&/()9876543XXddddJJJJJJhhhhhhhh\",\n"); sb.append("\t\t\t\t\"int" + i + "\":[1,-4543,112,0,1,10,100,87,34112, true, false, null],\n"); sb.append("\t\t\t\"ints" + i + "\":0,\n"); sb.append("\t\t\t\"false" + i + "\":false,\n"); sb.append("\t\t\t\"nil" + i + "\":false,\n"); sb.append("\t\t\t\"obj" + i + "\": null ,\n"); sb.append("\t\t\t\"obj" + i + "\":\n"); sb.append("\t\t\t\t[ true, \"normal string ascii only normal string ascii only\" ,\n"); sb.append("\t\t\t\t{\n"); sb.append("\t\t\t\t\"special-" + i + "\":" + "\"" + "\\\\f\\n\\r\\t\\u6532" + "\",\n"); sb.append("\t\t\t\t\"unicode-\\u0000- " + i + "\":\"\\u5656\",\n"); sb.append("\t\t\t\t\"bigdecimal" + i + "\":7817265.00000111,\n"); sb.append("\t\t\t\t\"bigdecimal-2-" + i + "\":127655512123456.761009E-123,\n"); sb.append("\t\t\t\t\"string-" + i + "\":\"lorem ipsum, ????????????.-,<!$%&/()9876543XXddddJJJJJJhhhhhhhh\",\n"); sb.append("\t\t\t\t\"int" + i + "\":[1,-4543,112,0,1,10,100,87,34112, true, false, null],\n"); sb.append("\t\t\t\t\"ints" + i + "\":0,\n"); sb.append("\t\t\t\t\"false" + i + "\":false,\n"); sb.append("\t\t\t\t\"nil" + i + "\":false,\n"); sb.append("\t\t\t\t\"obj" + i + "\": null \n"); sb.append("\t\t\t\t\n}\n"); sb.append("\t\t\t]\n"); sb.append("\t\t\n}\n\n\n\n \t\r "); if (i < count - 1) { sb.append(",\n"); } else { sb.append("\n"); } } sb.append("\n}\n"); sb.close(); return json; }
From source file:de.teamgrit.grit.report.PdfConcatenator.java
/** * Writes the closing part of the file.//from w w w . j a va 2 s.c o m * * @param file * the file * @throws IOException * Signals that an I/O exception has occurred. */ private static void writeClosing(File file) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("\\label{lastpage}"); writer.append("\\end{document}\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PdfConcatenator.java
/** * Writes the preamble and title to the file. * * @param file/*from w w w . j a va 2 s . com*/ * the file * @param exerciseName * the name of the exercise * @throws IOException * Signals that an I/O exception has occurred. */ private static void writePreamble(File file, String exerciseName) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("\\documentclass[a4paper,10pt,ngerman]{scrartcl} \n"); writer.append("\\usepackage[ngerman]{babel}\n"); writer.append("\\usepackage[utf8]{inputenc}"); writer.append("\\usepackage{pdfpages} \n"); writer.append("\\usepackage{grffile} \n"); writer.append("\\begin{document} \n"); writer.append("\\begin{titlepage}\n"); writer.append("\\begin{center}\n"); writer.append("\\textsc{\\LARGE Universitt Konstanz}\\\\[1.5cm]\n\n"); writer.append("{\\large Korrektur\n\n"); writer.append("\\rule{\\linewidth}{0.5mm}\\\\[0.4cm]\n"); writer.append("{\\fontfamily{qhv}\\huge\\bfseries ").append(exerciseName).append(" \\\\[0.4cm]}\n\n"); writer.append("\\rule{\\linewidth}{0.5mm}\\\\[0.5cm]\n\n"); writer.append("\\vfill\n"); writer.append("{\\large\\today\n"); writer.append("\\end{center}\n"); writer.append("\\end{titlepage}\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PdfConcatenator.java
/** * Writes the names of the students that didn't hand in a submission. * * @param file//from www . ja va 2 s.c o m * the file that gets written into. * @param studentWithoutSubmissions * a list with students who did not submit any solution. * @throws IOException * If something goes wrong when writing. */ private static void writeMissingStudents(File file, List<Student> studentWithoutSubmissions) throws IOException { // // the list of students who didn't hand in a submission // List<Student> missing = context.getPreprocessor() // .getStudentsWithoutSubmission(); // only write if there are any missing submissions if (!(studentWithoutSubmissions == null) && !(studentWithoutSubmissions.isEmpty())) { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("{\\LARGE\\bf Studenten welche nicht abgegeben haben:}\\\\\n\\\\"); writer.append("\\begin{minipage}{.5\\textwidth}\n"); writer.append("\\begin{itemize}\n"); for (int i = 0; i < studentWithoutSubmissions.size(); i += 2) { writer.append("\\item ").append(studentWithoutSubmissions.get(i).getName()).append("\n"); } writer.append("\\end{itemize}\n"); writer.append("\\end{minipage}"); writer.append("\\begin{minipage}{.5\\textwidth}\\raggedright\n"); writer.append("\\begin{itemize}\n"); for (int i = 1; i < studentWithoutSubmissions.size(); i += 2) { writer.append("\\item ").append(studentWithoutSubmissions.get(i).getName()).append("\n"); } writer.append("\\end{itemize}\n"); writer.append("\\end{minipage}\n"); writer.close(); } }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the compiler errors into the text file. * /* w ww .ja va2 s.c om*/ * @param file * File the compiler errors get written into. * @param submission * SubmissionObj the needed information gets taken from. * @throws IOException * If something goes wrong when writing. */ private static void writeCompilerErrors(File file, Submission submission) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("Compilerfehler\n"); for (String error : submission.getCheckingResult().getCompilerOutput().getCompilerErrors()) { writer.append(error + "\n"); } writer.close(); }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the header into the text file. * /*from w ww . ja va 2s. c o m*/ * @param file * File the overhead gets written into. * @param submission * SubmissionObj the needed information gets taken from. * @param courseName * the name of the course * @param exerciseName * the name of the exercise * @throws IOException * Signals that an I/O exception has occurred. */ private static void writeHeader(File file, Submission submission, String courseName, String exerciseName) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append(courseName); writer.append("bungsblatt :" + exerciseName + "\n\n"); writer.append(submission.getStudent().getName() + "\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the compiler output into the text file. * /*from w w w .ja v a 2 s .c o m*/ * @param file * File the compiler output gets written into. * @param submission * SubmissionObj the needed information gets taken from. * @throws IOException * If something goes wrong when writing. */ private static void writeCompilerOutput(File file, Submission submission) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("Compilerausgabe:\n"); for (String warning : submission.getCheckingResult().getCompilerOutput().getCompilerWarnings()) { writer.append(warning + "\n"); } for (String info : submission.getCheckingResult().getCompilerOutput().getCompilerInfos()) { writer.append(info + "\n"); } writer.append("\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the Overview into the text file. * /* w w w . j a va 2s. c o m*/ * @param file * File the overview gets written into. * @param submission * SubmissionObj the needed information gets taken from. * @throws IOException * If something goes wrong when writing. */ private static void writeOverview(File file, Submission submission) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("bersicht\n"); if (submission.getCheckingResult().getCompilerOutput().isCleanCompile()) { writer.append("Abgabe kompiliert\n"); } else { writer.append("Abgabe kompiliert nicht\n"); } writer.append("Testergebnis: " + submission.getCheckingResult().getTestResults().getPassedTestCount() + " von " + submission.getCheckingResult().getTestResults().getTestCount() + " Tests bestanden\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the test result into the text file. * /*from w w w. ja v a 2 s. co m*/ * @param file * File the test results get written into. * @param submission * SubmissionObj the needed information gets taken from. * @throws IOException * If something goes wrong when writing. */ private static void writeTestResult(File file, Submission submission) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("Testergebnis\n"); if (submission.getCheckingResult().getTestResults().getDidTest()) { for (int i = 0; i < submission.getCheckingResult().getTestResults().getResults().size(); i++) { if (submission.getCheckingResult().getTestResults().getResults().get(i).wasSuccessful()) { writer.append("Test " + i + "\tpassed\n"); } else { writer.append("Test " + i + "\tfailed\n"); } } } else { writer.append("Keine Tests vorhanden.\n"); } writer.close(); }