List of usage examples for org.apache.commons.io.output FileWriterWithEncoding close
public void close() throws IOException
From source file:de.teamgrit.grit.report.PdfConcatenator.java
/** * Writes the closing part of the file.// w ww.j a v a 2 s . co 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:com.bluexml.side.util.documentation.LogSave.java
public static void toXml(SIDELog log, String fileName, File folder) throws Exception { folder.mkdirs();/* ww w . ja va 2 s . co m*/ FileWriterWithEncoding fos; File file = new File(folder, fileName); file.createNewFile(); fos = new FileWriterWithEncoding(file, "UTF-8"); toXml(log, fos); fos.close(); }
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(); }/*w w w . ja va 2 s . c om*/ 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.teamgrit.grit.report.PlainGenerator.java
/** * Writes the header into the text file. * /*from www .j a v a2 s. c om*/ * @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.TexGenerator.java
/** * Writes the Preamble into the .tex file. * //www .j a v a 2s. com * @param file * File the Preamble gets written into. * @throws IOException * If something goes wrong when writing. */ private static void writePreamble(File file) throws IOException { final File preamble = new File( Paths.get(System.getProperty("user.dir"), "res", "tex", "report_preamble.tex").toUri()); String preambleToString = FileUtils.readFileToString(preamble, "UTF-8"); FileWriterWithEncoding writer = new FileWriterWithEncoding(file, "UTF-8", true); writer.append(preambleToString); writer.append("\n\n"); writer.close(); }
From source file:com.bluexml.side.util.documentation.LogSave.java
/** * Render a SIDELog to a xml file using the given fileName in the given * folderName/* ww w . ja va 2s . c o m*/ * * @param log * @param fileName * @param folderName * @throws Exception */ public static void toXml(SIDELog log, String fileName, String folderName) throws Exception { IFolder folder = IFileHelper.createFolder(folderName); File f = IFileHelper.getFile(folder); FileWriterWithEncoding fos; File file = new File(f, fileName); file.createNewFile(); fos = new FileWriterWithEncoding(file, "UTF-8"); toXml(log, fos); IFileHelper.refreshFolder(folder); fos.close(); }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the compiler errors into the text file. * //from www . j a va 2s . co 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. * //from www . ja va 2 s. c o m * @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: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 . j av a2 s . co m * * @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); } }
From source file:de.teamgrit.grit.report.PlainGenerator.java
/** * Writes the compiler output into the text file. * //from w w w .j ava2s . c om * @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(); }