List of usage examples for java.io PrintWriter println
public void println()
From source file:com.espertech.esper.antlr.ASTUtil.java
/** * Print the token stream to the logger. * @param tokens to print/*from w ww. j av a 2 s . co m*/ */ public static void printTokens(CommonTokenStream tokens) { if (log.isDebugEnabled()) { List tokenList = tokens.getTokens(); StringWriter writer = new StringWriter(); PrintWriter printer = new PrintWriter(writer); for (int i = 0; i < tokens.size(); i++) { Token t = (Token) tokenList.get(i); String text = t.getText(); if (text.trim().length() == 0) { printer.print("'" + text + "'"); } else { printer.print(text); } printer.print('['); printer.print(t.getType()); printer.print(']'); printer.print(" "); } printer.println(); log.debug("Tokens: " + writer.toString()); } }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step11GoldDataStatistics.java
/** * Relevant sentences per document (per query) *///from w ww. j av a 2 s. com public static void statistics6(File inputDir, File outputDir) throws IOException { PrintWriter pw = new PrintWriter(new FileWriter(new File(outputDir, "stats6.csv"))); SortedMap<String, DescriptiveStatistics> result = new TreeMap<>(); result.put("relevantSentencesDocumentPercent", new DescriptiveStatistics()); // print header for (String mapKey : result.keySet()) { pw.printf(Locale.ENGLISH, "%s\t%sStdDev\t", mapKey, mapKey); } pw.println(); // iterate over query containers for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); System.out.println("Processing " + f); for (QueryResultContainer.SingleRankedResult rankedResult : queryResultContainer.rankedResults) { if (rankedResult.plainText != null && !rankedResult.plainText.isEmpty()) { int relevantSentences = 0; int totalSentences = 0; if (rankedResult.goldEstimatedLabels != null) { for (QueryResultContainer.SingleSentenceRelevanceVote sentenceRelevanceVote : rankedResult.goldEstimatedLabels) { totalSentences++; if (Boolean.valueOf(sentenceRelevanceVote.relevant)) { relevantSentences++; } } // percent relevant result.get("relevantSentencesDocumentPercent") .addValue((double) relevantSentences / (double) totalSentences); } } } } // print results // print header for (String mapKey : result.keySet()) { pw.printf(Locale.ENGLISH, "%.3f\t%.3f\t", result.get(mapKey).getMean(), result.get(mapKey).getStandardDeviation()); } pw.close(); }
From source file:com.atlassian.clover.reporters.console.ConsoleReporter.java
private static void printPcBar(PrintWriter out, String summary, float amt) { // pad out to 32 spaces from the left. int padLen = 32 - summary.length(); out.print(String.format("%" + (padLen) + "s", " ")); final int len = 80; final int pc = (int) (amt * len); for (int i = 0; i <= len; i++) { if (i < pc) { out.print(Color.make(" ").bg().green()); } else {/*from ww w . j a va2 s .co m*/ out.print(Color.make(" ").bg().red()); } } out.println(); }
From source file:com.abstratt.mdd.frontend.textuml.renderer.TextUMLRenderingUtils.java
public static void renderStereotypeApplications(PrintWriter writer, NamedElement element, boolean newLine) { List<EObject> applications = element.getStereotypeApplications(); if (applications.isEmpty()) return;/*from w w w .j a va 2s . c om*/ StringBuilder builder = new StringBuilder(); builder.append("["); for (EObject application : applications) { renderStereotypeApplication(element, builder, application); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); builder.append("]"); writer.print(builder); if (newLine) writer.println(); else writer.print(' '); }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step11GoldDataStatistics.java
/** * Other statistics: we want to report how many documents and sentences * were judged and how many were found relevant among those. * Having the total + standard deviation over queries is enough. *///w ww . j a v a2s .co m public static void statistics5(File inputDir, File outputDir) throws IOException { PrintWriter pw = new PrintWriter(new FileWriter(new File(outputDir, "stats5.csv"))); SortedMap<String, DescriptiveStatistics> result = new TreeMap<>(); result.put("annotatedDocumentsPerQuery", new DescriptiveStatistics()); result.put("annotatedSentencesPerQuery", new DescriptiveStatistics()); result.put("relevantSentencesPerQuery", new DescriptiveStatistics()); // print header for (String mapKey : result.keySet()) { pw.printf(Locale.ENGLISH, "%s\t%sStdDev\t", mapKey, mapKey); } pw.println(); // iterate over query containers for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); System.out.println("Processing " + f); int annotatedDocuments = 0; int relevantSentences = 0; int totalSentences = 0; for (QueryResultContainer.SingleRankedResult rankedResult : queryResultContainer.rankedResults) { if (rankedResult.plainText != null && !rankedResult.plainText.isEmpty()) { annotatedDocuments++; if (rankedResult.goldEstimatedLabels != null) { for (QueryResultContainer.SingleSentenceRelevanceVote sentenceRelevanceVote : rankedResult.goldEstimatedLabels) { totalSentences++; if (Boolean.valueOf(sentenceRelevanceVote.relevant)) { relevantSentences++; } } } } } result.get("annotatedDocumentsPerQuery").addValue(annotatedDocuments); result.get("annotatedSentencesPerQuery").addValue(totalSentences); result.get("relevantSentencesPerQuery").addValue(relevantSentences); } // print results // print header for (String mapKey : result.keySet()) { pw.printf(Locale.ENGLISH, "%.3f\t%.3f\t", result.get(mapKey).getMean(), result.get(mapKey).getStandardDeviation()); } pw.close(); }
From source file:com.espertech.esper.antlr.ASTUtil.java
private static void renderNode(char[] ident, Tree node, PrintWriter printer) { printer.print(ident);/*from w ww. j a va2s . co m*/ if (node == null) { printer.print("NULL NODE"); } else { printer.print(node.getText()); printer.print(" ["); printer.print(node.getType()); printer.print("]"); if (node.getText() == null) { printer.print(" (null value in text)"); } else if (node.getText().contains("\\")) { int count = 0; for (int i = 0; i < node.getText().length(); i++) { if (node.getText().charAt(i) == '\\') { count++; } } printer.print(" (" + count + " backlashes)"); } } printer.println(); }
From source file:it.tidalwave.imageio.test.ImageReaderTestSupport.java
/******************************************************************************************************************* * * ******************************************************************************************************************/ public static void dumpRasterAsText(final @Nonnull Raster raster, final @Nonnull PrintWriter pw) { final int width = raster.getWidth(); final int height = raster.getHeight(); final int bandCount = raster.getNumBands(); logger.fine("Dumping raster %d x %d x %d", width, height, bandCount); for (int y = 0; y < height; y++) { for (int b = 0; b < bandCount; b++) { pw.printf("y=%04d b=%1d : ", y, b); for (int x = 0; x < width; x++) { final int sample = raster.getSample(x, y, b) & 0xffff; pw.printf("%04x ", sample); }//from ww w . ja v a 2 s . c o m pw.println(); } } }
From source file:mx.unam.ecologia.gye.coalescence.app.CreateSampleConfiguration.java
protected static final void writeSampleConfig(List leaves, String fname) { try {//from w ww. j a va2s. c o m FileOutputStream fout = new FileOutputStream(fname); PrintWriter pw = new PrintWriter(fout); HaplotypeFreqSet len1 = new HaplotypeFreqSet(new CompoundSequenceLengthComparator()); HaplotypeFreqSet len2 = new HaplotypeFreqSet(new CompoundSequenceLengthComparator()); HaplotypeFreqSet ident = new HaplotypeFreqSet(new CompoundSequenceIdentityComparator()); for (int i = 0; i < leaves.size(); i++) { UniParentalGene upgene = (UniParentalGene) leaves.get(i); CompoundSequence h = upgene.getCompoundSequence(); len1.add(h); ident.add(h); CompoundSequence cs = h.getCopy(); cs.setLocus(true); len2.add(cs); int numloc = h.getSequenceCount(); for (int n = 0; n < numloc; n++) { Sequence s = h.get(n); pw.print(s.toFullString()); pw.print(" "); } pw.println(); } //print length as locus pw.println(); pw.println("Haplotypes by Length (locus)"); pw.println(len2.toString()); pw.println("Haplotypes by Length (multilocus)"); pw.println(len1.toString()); pw.println("Haplotypes by Identity"); pw.println(ident.toFullString()); pw.println(); //System.out.println("TEST"); //ident.sort(new CSAncestryComparator()); //System.out.println(ident.toFullString()); //System.out.println(ident.findMostFrequent() + 1); pw.flush(); pw.close(); fout.close(); } catch (IOException ex) { CreateSampleConfiguration.log.error("writeSampleConfig()", ex); } }
From source file:com.javiermoreno.springboot.mvc.minimal.httpd.PingController.java
@RequestMapping(value = "/long", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)/*from w ww. jav a2 s . c om*/ void longPing(HttpServletResponse response) throws IOException, InterruptedException { response.setBufferSize(0); PrintWriter out = response.getWriter(); out.println(); out.flush(); for (int i = 0; i < 60 * 5; i++) { out.format("Current server time: %s.\r\n", new Date()); out.flush(); Thread.sleep(1000); } }