Example usage for java.io PrintWriter println

List of usage examples for java.io PrintWriter println

Introduction

In this page you can find the example usage for java.io PrintWriter println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminates the line.

Usage

From source file:edu.illinois.cs.cogcomp.wikifier.utils.freebase.cleanDL.java

private static void outputMentions() throws FileNotFoundException {
    PrintWriter w = new PrintWriter("/Users/Shyam/mention.eval.dl.out");
    for (String doc : mentions.keySet()) {
        for (DocMention tmp : mentions.get(doc))
            w.println(doc + "\t" + tmp.start + "\t" + tmp.end + "\t" + tmp.mention);
    }//from  w  w w.j ava 2s  .  co  m
    w.close();
}

From source file:gov.nist.appvet.tool.sigverifier.util.ReportUtil.java

/**
 * This method returns report information to the AppVet ToolAdapter as ASCII
 * text and cannot attach a file to the response.
 *//* w ww.  j a  va  2 s.  com*/
public static boolean sendInHttpResponse(HttpServletResponse response, String reportText,
        ToolStatus reportStatus) {
    try {
        response.setStatus(HttpServletResponse.SC_OK); // HTTP 200
        response.setContentType("text/html");
        response.setHeader("toolrisk", reportStatus.name());
        PrintWriter out = response.getWriter();
        out.println(reportText);
        out.flush();
        out.close();
        log.debug("Returned report");
        return true;
    } catch (IOException e) {
        log.error(e.toString());
        return false;
    }
}

From source file:DebugUtilities.java

public static void printContainerComponents(java.awt.Container cont, PrintWriter writer, String prefix,
        boolean recurse) {
    java.awt.Component[] comps = cont.getComponents();

    if (comps.length < 1) {
        writer.println(prefix + "Contains no components.");
    }/*from   www .ja va  2s  .  c om*/

    for (int i = 0; i < comps.length; ++i) {
        DebugUtilities.printClassHierarchy(comps[i].getClass(), writer, prefix + "[" + i + "]");

        if (recurse) {
            Class c = java.awt.Container.class;
            if (c.isAssignableFrom(comps[i].getClass())) {
                DebugUtilities.printContainerComponents((java.awt.Container) comps[i], writer,
                        (prefix + "[" + i + "] "), recurse);
            }
        }
    }
}

From source file:Main.java

/**
 * Print a string representation of the current stack state of all the active threads.
 *//*from   w  ww  . j ava  2  s.c  o  m*/
public static void printStackTraces(PrintWriter writer) {
    Map<Thread, StackTraceElement[]> map;
    try {
        map = Thread.getAllStackTraces();
    } catch (Throwable e) {
        writer.println("Failed to obtain stack traces: " + e);
        return;
    }
    if (map == null) {
        writer.println("No stack traces available");
        return;
    }
    for (Entry<Thread, StackTraceElement[]> entry : map.entrySet())
        printStackTrace(writer, entry.getKey(), entry.getValue());
    writer.flush();
}

From source file:ISMAGS.CommandLineInterface.java

private static void printMotifs(Set<MotifInstance> motifs, String output) throws IOException {
    PrintWriter out = new PrintWriter(new File(output));
    for (MotifInstance m : motifs) {
        out.println(m);
    }//from   w w w  .ja  v a  2 s .  c o m
    out.close();
}

From source file:Main.java

private static String createPKCS11ConfigFile(String pkcs11LibPath) {
    File f = null;/*from w  w w . j  av  a  2 s  .c o  m*/
    PrintWriter writer = null;
    try {
        f = File.createTempFile("pkcs11", ".cfg");
        f.deleteOnExit();
        writer = new PrintWriter(new FileOutputStream(f));
        writer.println("name = verinice");
        writer.println("description = verinice PKCS#11 configuration");
        writer.println("library = " + pkcs11LibPath);
        writer.close();
    } catch (IOException e) {
        return null;
    } finally {
        if (writer != null)
            writer.close();
    }

    return f.getAbsolutePath();
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step7bConvArgRankProducer.java

@SuppressWarnings("unchecked")
public static void prepareData(String[] args) throws Exception {
    String inputDir = args[0];/*from  w w w  .j  a v  a2s.  c o m*/
    File outputDir = new File(args[1]);

    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    List<File> files = IOHelper.listXmlFiles(new File(inputDir));

    // take only the gold data for this task
    String prefix = "all_DescendingScoreArgumentPairListSorter";
    Iterator<File> iterator = files.iterator();
    while (iterator.hasNext()) {
        File file = iterator.next();

        if (!file.getName().startsWith(prefix)) {
            iterator.remove();
        }
    }

    int totalArgumentsCounter = 0;

    DescriptiveStatistics statsPerTopic = new DescriptiveStatistics();

    for (File file : files) {
        List<AnnotatedArgumentPair> argumentPairs = (List<AnnotatedArgumentPair>) XStreamTools.getXStream()
                .fromXML(file);

        String name = file.getName().replaceAll(prefix, "").replaceAll("\\.xml", "");

        PrintWriter pw = new PrintWriter(new File(outputDir, name + ".csv"), "utf-8");
        pw.println("#id\trank\targument");

        Graph graph = buildGraphFromPairs(argumentPairs);

        Map<String, Argument> arguments = collectArguments(argumentPairs);

        int argumentsPerTopicCounter = arguments.size();

        PageRank pageRank = new PageRank();
        pageRank.setVerbose(true);
        pageRank.init(graph);

        for (Node node : graph) {
            String id = node.getId();
            double rank = pageRank.getRank(node);

            System.out.println(id);

            Argument argument = arguments.get(id);

            String text = Step7aLearningDataProducer.multipleParagraphsToSingleLine(argument.getText());

            pw.printf(Locale.ENGLISH, "%s\t%.5f\t%s%n", argument.getId(), rank, text);
        }

        totalArgumentsCounter += argumentsPerTopicCounter;
        statsPerTopic.addValue(argumentsPerTopicCounter);

        pw.close();
    }

    System.out.println("Total gold arguments: " + totalArgumentsCounter);
    System.out.println(statsPerTopic);
}

From source file:Main.java

public static int numberBounce(PrintWriter out, BufferedReader in) {
    try {/*  ww w . j  a  va2s .  c  o  m*/
        String theString = in.readLine();
        if (theString != null) {
            int num = Integer.parseInt(theString);

            ++num;
            out.println("" + num);
            return num;
        }
    } catch (IOException e) {
        Log.e("NUMBER_BOUNCE_METHOD", e.getMessage());
    }
    return -1;
}

From source file:gov.nist.appvet.tool.sigverifier.util.FileUtil.java

public static boolean saveReport(String reportContent, String reportFilePath) {
    PrintWriter out;
    try {/*from   w  w  w. j  av a2s.c o  m*/
        out = new PrintWriter(reportFilePath);
        out.println(reportContent);
        out.flush();
        out.close();
        log.debug("Saved " + reportFilePath);
        return true;
    } catch (FileNotFoundException e) {
        log.error(e.toString());
        return false;
    }
}

From source file:jvmoptions.OptionAnalyzer.java

static void toCSV(Path json) throws IOException {
    Map<String, Map<String, String>> map = readJson(json);
    try (BufferedWriter w = Files.newBufferedWriter(Paths.get("result", filename("csv")))) {
        PrintWriter pw = new PrintWriter(w);
        pw.println("name,description,type,6,7,8,6.default,7.default,8.default,kind,file");
        map.keySet().stream().sorted().map(k -> {
            Map<String, String> m = map.get(k);
            return String.format("%s, \" %s\", %s", k, m.get("description"),
                    String.join(", ", m.get("type"), m.get("java6"), m.get("java7"), m.get("java8"),
                            m.get("java6.default"), m.get("java7.default"), m.get("java8.default"),
                            m.get("kind"), m.get("file")));
        }).forEach(pw::println);/* w w  w  . ja  v a2s. co m*/
    }
}