List of usage examples for org.apache.commons.io.output FileWriterWithEncoding FileWriterWithEncoding
public FileWriterWithEncoding(File file, CharsetEncoder encoding, boolean append) throws IOException
From source file:de.teamgrit.grit.report.PdfConcatenator.java
/** * Writes the preamble and title to the file. * * @param file/* w ww. j ava 2 s. co m*/ * 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.PlainGenerator.java
/** * Writes the compiler errors into the text file. * /*from ww w .j a v a 2s . c o m*/ * @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.TexGenerator.java
/** * Writes the closing into the TeX file. * //w w w.j a va2 s .c om * @param file * File the closing gets written into. * @throws IOException * If something goes wrong when writing. */ private static void writeClosing(File file) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("\\end{student}\n"); writer.append("\\label{lastpage}"); writer.append("\\end{document}\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the compiler output into the text file. * /*from w ww . j a v a 2 s .co 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.PdfConcatenator.java
/** * Write the pdfs to the file.//ww w . j a v a2 s . com * * @param outFile * the out file * @param folderWithPdfs * the folder with pdfs * @throws IOException * Signals that an I/O exception has occurred. */ private static void writeFiles(File outFile, Path folderWithPdfs) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(outFile, "UTF-8", true); File[] files = folderWithPdfs.toFile().listFiles(); if (files.length > 0) { for (File file : files) { // We only want the the PDFs as input if ("pdf".equals(FilenameUtils.getExtension(file.getName()))) { writer.append("\\includepdf[pages={1-}]{").append(file.getAbsolutePath()).append("} \n"); } } } else { LOGGER.warning("No Reports available in the specified folder: " + folderWithPdfs.toString()); } writer.close(); }
From source file:de.teamgrit.grit.report.TexGenerator.java
/** * Writes the compiler errors into the TeX file. * //from www . j av a 2 s .c o m * @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("\\paragraph{Compilerfehler}~\\\\\n"); writer.append("\\begin{lstlisting}[language=bash, breaklines=true, " + "basicstyle=\\color{black}\\footnotesize\\ttfamily,numberstyle" + "=\\tiny\\color{black}]\n"); for (String error : submission.getCheckingResult().getCompilerOutput().getCompilerErrors()) { writer.append(error + "\n"); } writer.append("\\end{lstlisting}\n"); writer.close(); }
From source file:de.teamgrit.grit.report.PdfConcatenator.java
/** * Writes the closing part of the file./*from w w w.ja va 2s . com*/ * * @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.PlainGenerator.java
/** * Writes the failed tests into the text file. * // w w w .j av a2s . c om * @param file * File the failed tests get written into. * @param submission * SubmissionObj the needed information gets taken from. * @throws IOException * If something goes wrong when writing. */ private static void writeFailedTests(File file, Submission submission) throws IOException { FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append("Fehlerhafte Tests\n"); for (int i = 0; i < submission.getCheckingResult().getTestResults().getResults().size(); i++) { if (!(submission.getCheckingResult().getTestResults().getResults().get(i).wasSuccessful())) { writer.append("- Test" + i + "\n"); for (Failure fail : submission.getCheckingResult().getTestResults().getResults().get(i) .getFailures()) { writer.append(fail.toString() + "\n"); } } } writer.close(); }
From source file:de.teamgrit.grit.report.TexGenerator.java
/** * Writes the compiler output into the TeX file. * //w w w . j ava2 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("\\paragraph{Compilerausgabe}~\\\\\n"); writer.append("\\color{black}\n"); writer.append("\\begin{lstlisting}[language=bash, " + "breaklines=true]{Warnings}\n"); for (String warning : submission.getCheckingResult().getCompilerOutput().getCompilerWarnings()) { writer.append(warning + "\n"); } writer.append("\\end{lstlisting}\n"); writer.append("\\begin{lstlisting}[language=bash, " + "breaklines=true]{Infos}\n"); for (String info : submission.getCheckingResult().getCompilerOutput().getCompilerInfos()) { writer.append(info + "\n"); } writer.append("\\end{lstlisting}\n"); writer.close(); }
From source file:com.bluexml.side.util.documentation.LogSave.java
/** * Will build a unique log file from all the xml files available in the * given folder/*from w w w. java 2 s .c om*/ * * @param folderName * @throws Exception */ public static void buildGeneraLogFile(String folderName) throws Exception { IFolder logFolder = IFileHelper.createFolder(folderName); IFolder tmpFolder = IFileHelper.createFolder(logFolder.getFullPath().append(LOG_TEMP_FOLDER).toOSString()); IFolder docFolder = IFileHelper.createFolder(logFolder.getFullPath().append(LOG_DOC_FOLDER).toOSString()); // We create the top root element of the general log file Element rootNode = new Element("logRoot"); //$NON-NLS-1$ Document doc = new Document(); ProcessingInstruction pi = new ProcessingInstruction("xml-stylesheet", //$NON-NLS-1$ "type='text/xsl' href='stylesheet/log2html.xsl'"); //$NON-NLS-1$ doc.addContent(pi); doc.setRootElement(rootNode); // For all .xml files we get their content and add it to general log // file agregateLogs(rootNode, tmpFolder); // We search for xml file in stamp folder to know which generator have // been deployed addGeneratorStamp(rootNode, logFolder); // We search for all docs addDocLink(rootNode, docFolder); // We create the general log file IFileHelper.deleteFile(logFolder.getFullPath() + File.separator + LOG_FILE_NAME); IFile genLog = IFileHelper.createFile(logFolder, LOG_FILE_NAME); if (genLog != null) { File genLogFile = IFileHelper.getFile(genLog); FileWriterWithEncoding writer = new FileWriterWithEncoding(genLogFile, encoding, false); Format outputFormat = Format.getCompactFormat(); outputFormat.setEncoding(encoding); XMLOutputter outputter = new XMLOutputter(outputFormat); outputter.output(doc, writer); writer.close(); moveStaticRessources(logFolder, genLogFile); } }