当前位置: 首页>>代码示例>>Java>>正文


Java FileWriterWithEncoding.append方法代码示例

本文整理汇总了Java中org.apache.commons.io.output.FileWriterWithEncoding.append方法的典型用法代码示例。如果您正苦于以下问题:Java FileWriterWithEncoding.append方法的具体用法?Java FileWriterWithEncoding.append怎么用?Java FileWriterWithEncoding.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.output.FileWriterWithEncoding的用法示例。


在下文中一共展示了FileWriterWithEncoding.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNewStateFile

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Creates an empty state file.
 *
 * @param state
 *            the path to the state file
 * @throws IOException
 *             if the file can't be created
 */
static void createNewStateFile(Path state) throws IOException {
    File file = state.toFile();
    file.createNewFile();

    if (Files.exists(file.toPath(), LinkOption.NOFOLLOW_LINKS)) {
        Files.delete(file.toPath());
    }

    FileWriterWithEncoding writer =
            new FileWriterWithEncoding(file, "UTF-8", true);

    writer.append("<?xml version=\"1.0\" "
            + "encoding=\"UTF-8\" standalone=\"no\"?>");

    writer.append("<state>");
    writer.append("<courses>");
    writer.append("</courses>");
    writer.append("<connections>");
    writer.append("</connections>");
    writer.append("</state>");

    writer.close();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:32,代码来源:BootHelpers.java

示例2: writeCompilerOutput

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the compiler output into the text file.
 * 
 * @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();

}
 
开发者ID:team-grit,项目名称:grit,代码行数:30,代码来源:PlainGenerator.java

示例3: writeFailedTests

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the failed tests into the text file.
 * 
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:32,代码来源:PlainGenerator.java

示例4: writeOverview

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the Overview into the text file.
 * 
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:32,代码来源:PlainGenerator.java

示例5: writeCompilerErrors

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the compiler errors into the TeX file.
 * 
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:28,代码来源:TexGenerator.java

示例6: writeCompilerOutput

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the compiler output into the TeX file.
 * 
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:36,代码来源:TexGenerator.java

示例7: writeHeader

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the header into the TeX file.
 * 
 * @param file
 *            File the overhead gets written into.
 * @param submission
 *            SubmissionObj the needed information gets taken from.
 * @param courseName
 *            the name of the course the exercise belongs to
 * @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,
        final String courseName, final String exerciseName)
        throws IOException {
    FileWriterWithEncoding writer = new FileWriterWithEncoding(file,
            "UTF-8", true);

    writer.append("\\newcommand{\\studycourse}{" + courseName + "}\n");
    writer.append("\\newcommand{\\assignmentnumber}{" + exerciseName
            + "}\n");
    writer.append("\\begin{document}\n");

    writer.append("\\begin{student}{" + submission.getStudent().getName()
            + "}\n");

    writer.close();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:31,代码来源:TexGenerator.java

示例8: writeOverview

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the Overview into the .tex file.
 * 
 * @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("\\paragraph{Übersicht}~\\\\\n");

    CheckingResult checkingResult = submission.getCheckingResult();
    if (checkingResult.getCompilerOutput().isCleanCompile()) {
        writer.append("Abgabe kompiliert \\hfill \\textcolor{green}{JA}\\\\");
    } else {
        writer.append("Abgabe kompiliert \\hfill \\textcolor{red}{NEIN}\\\\ \n");
    }
    writer.append("Testergebnis \\hfill "
            + checkingResult.getTestResults().getPassedTestCount()
            + " von " + checkingResult.getTestResults().getTestCount()
            + " Tests bestanden\n");

    writer.close();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:31,代码来源:TexGenerator.java

示例9: createBigStack

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
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();
        }

        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;

    }
 
开发者ID:salyh,项目名称:jsr353-benchmark,代码行数:31,代码来源:CreateJsonTestFiles.java

示例10: writeCompilerErrors

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the compiler errors into the text file.
 * 
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:24,代码来源:PlainGenerator.java

示例11: writeTestResult

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the test result into the .tex file.
 * 
 * @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("\\paragraph{Testergebnis}~\\\\\n");

    TestOutput testResults = submission.getCheckingResult()
            .getTestResults();

    if (testResults.getDidTest() && (testResults.getTestCount() > 0)) {
        writer.append("Bestandene Tests \\hfill\\progressbar[subdivisions="
                + testResults.getTestCount()
                + ", ticksheight=1, emptycolor=red, filledcolor=green]{"
                + (testResults.getPassedTestCount() / testResults
                        .getTestCount())
                + "} \\\\\n");
        for (int i = 0; i < testResults.getResults().size(); i++) {
            if (testResults.getResults().get(i).wasSuccessful()) {
                writer.append("Test " + i + "\\hfill \\checkedbox \\\\\n");
            } else {
                writer.append("\\textcolor{red}{Test " + i
                        + "\\hfill \\XBox} \\ \\\n");
            }
        }
        writer.append("\\pagebreak\n");
    } else {
        writer.append("Keine Tests vorhanden.\n");
    }
    writer.close();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:41,代码来源:TexGenerator.java

示例12: writePreamble

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the preamble and title to the file.
 *
 * @param file
 *            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 Universität 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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:37,代码来源:PdfConcatenator.java

示例13: writeClosing

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the closing part of the file.
 *
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:18,代码来源:PdfConcatenator.java

示例14: writeMissingStudents

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the names of the students that didn't hand in a submission.
 *
 * @param file
 *            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();
    }
}
 
开发者ID:team-grit,项目名称:grit,代码行数:48,代码来源:PdfConcatenator.java

示例15: writeClosing

import org.apache.commons.io.output.FileWriterWithEncoding; //导入方法依赖的package包/类
/**
 * Writes the closing into the TeX file.
 * 
 * @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();
}
 
开发者ID:team-grit,项目名称:grit,代码行数:19,代码来源:TexGenerator.java


注:本文中的org.apache.commons.io.output.FileWriterWithEncoding.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。