Java Code Examples for java.io.PrintStream#append()

The following examples show how to use java.io.PrintStream#append() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ICTree.java    From swift-t with Apache License 2.0 6 votes vote down vote up
public void log(PrintStream icOutput, String codeTitle) {
  StringBuilder ic = new StringBuilder();
  try {
    icOutput.append("\n\n" + codeTitle + ": \n" +
        "============================================\n");
    prettyPrint(ic) ;
    icOutput.append(ic.toString());
    icOutput.flush();
  } catch (Exception e) {
    icOutput.append("ERROR while generating code. Got: "
        + ic.toString());
    icOutput.flush();
    e.printStackTrace();
    throw new STCRuntimeError("Error while generating IC: " +
    e.toString());
  }
}
 
Example 2
Source File: MeasurementFormatter.java    From kafka-metrics with Apache License 2.0 6 votes vote down vote up
public void writeTo(MeasurementV1 measurement, PrintStream output) {
    output.append(measurement.getName());
    for (java.util.Map.Entry<String, String> tag : measurement.getTags().entrySet()) {
        output.append(",");
        output.append(tag.getKey());
        output.append("=");
        output.append(tag.getValue());
    }
    output.append(" [" + date.format(new Date(measurement.getTimestamp())) + "] ");
    output.append("\n");
    for (java.util.Map.Entry<String, Double> field : measurement.getFields().entrySet()) {
        output.append(field.getKey());
        output.append("=");
        output.append(field.getValue().toString());
        output.append("\t");
    }
    output.append("\n\n");
}
 
Example 3
Source File: ScanUtil.java    From fluo with Apache License 2.0 6 votes vote down vote up
/**
 * Generate JSON format as result of the scan.
 *
 * @since 1.2
 */
private static void generateJson(CellScanner cellScanner, Function<Bytes, String> encoder,
    PrintStream out) throws JsonIOException {
  Gson gson = new GsonBuilder().serializeNulls().setDateFormat(DateFormat.LONG)
      .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setVersion(1.0)
      .create();

  Map<String, String> json = new LinkedHashMap<>();
  for (RowColumnValue rcv : cellScanner) {
    json.put(FLUO_ROW, encoder.apply(rcv.getRow()));
    json.put(FLUO_COLUMN_FAMILY, encoder.apply(rcv.getColumn().getFamily()));
    json.put(FLUO_COLUMN_QUALIFIER, encoder.apply(rcv.getColumn().getQualifier()));
    json.put(FLUO_COLUMN_VISIBILITY, encoder.apply(rcv.getColumn().getVisibility()));
    json.put(FLUO_VALUE, encoder.apply(rcv.getValue()));
    gson.toJson(json, out);
    out.append("\n");

    if (out.checkError()) {
      break;
    }
  }
  out.flush();
}
 
Example 4
Source File: RuleException.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
@Override
public void printStackTrace(PrintStream ps) {
    ps.print("<exception>");
    if (getResult() != null) {
        ps.print(result.toString());
    }
    ps.append("<exceptionTrace>");

    Throwable cause = getCause();
    if (cause == null) {
        super.printStackTrace(ps);
    } else {
        ps.println(this);
        ps.print("Caused by: ");
        cause.printStackTrace(ps);
    }
    ps.append("</exceptionTrace>");
    ps.println("</exception>");
}
 
Example 5
Source File: PatternBlock.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public void saveXml(PrintStream s) {
	s.append("<pat_block ");
	s.append("offset=\"");
	s.print(offset);
	s.append("\" ");
	s.append("nonzero=\"");
	s.print(nonzerosize);
	s.append("\">\n");
	for (int i = 0; i < maskvec.size(); ++i) {
		s.append("  <mask_word ");
		s.append("mask=\"0x");
		s.append(Utils.toUnsignedIntHex(maskvec.get(i)));
		s.append("\" ");
		s.append("val=\"0x");
		s.append(Utils.toUnsignedIntHex(valvec.get(i)));
		s.append("\"/>\n");
	}
	s.append("</pat_block>\n");
}
 
Example 6
Source File: SMOException.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
@Override
public void printStackTrace(PrintStream ps) {
    ps.print("<exception>");
    if (getResult() != null) {
        ps.print(result.toString());
    }
    ps.append("<exceptionTrace>");

    Throwable cause = getCause();
    if (cause == null) {
        super.printStackTrace(ps);
    } else {
        ps.println(this);
        ps.print("Caused by: ");
        cause.printStackTrace(ps);
    }
    ps.append("</exceptionTrace>");
    ps.println("</exception>");
}
 
Example 7
Source File: SubtableSymbol.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void saveXml(PrintStream s) {
	if (decisiontree == null) {
		return; // Not fully formed
	}
	s.append("<subtable_sym");
	saveSleighSymbolXmlHeader(s);
	s.append(" numct=\"").print(construct.size());
	s.append("\">\n");
	for (int i = 0; i < construct.size(); ++i) {
		construct.get(i).saveXml(s);
	}
	decisiontree.saveXml(s);
	s.append("</subtable_sym>\n");
}
 
Example 8
Source File: ExpressionEvaluationException.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
public void printStackTrace(PrintStream s) {
	if (s != null) {
		s.append("Error node: ");
		s.append(getErrorNodeAsString());
		s.append('\n');
	}
	super.printStackTrace(s);
}
 
Example 9
Source File: AddrSpace.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void saveXmlAttributes(PrintStream s, long offset) { // Save address
	// as XML
	// attributes
	XmlUtils.a_v(s, "space", getName()); // Just append the proper
	// attributes
	s.append(' ');
	s.append("offset=\"");
	printOffset(s, offset);
	s.append("\"");
}
 
Example 10
Source File: AbstractYarnClusterDescriptor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public String getClusterDescription() {

	try {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		PrintStream ps = new PrintStream(baos);

		YarnClusterMetrics metrics = yarnClient.getYarnClusterMetrics();

		ps.append("NodeManagers in the ClusterClient " + metrics.getNumNodeManagers());
		List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING);
		final String format = "|%-16s |%-16s %n";
		ps.printf("|Property         |Value          %n");
		ps.println("+---------------------------------------+");
		int totalMemory = 0;
		int totalCores = 0;
		for (NodeReport rep : nodes) {
			final Resource res = rep.getCapability();
			totalMemory += res.getMemory();
			totalCores += res.getVirtualCores();
			ps.format(format, "NodeID", rep.getNodeId());
			ps.format(format, "Memory", res.getMemory() + " MB");
			ps.format(format, "vCores", res.getVirtualCores());
			ps.format(format, "HealthReport", rep.getHealthReport());
			ps.format(format, "Containers", rep.getNumContainers());
			ps.println("+---------------------------------------+");
		}
		ps.println("Summary: totalMemory " + totalMemory + " totalCores " + totalCores);
		List<QueueInfo> qInfo = yarnClient.getAllQueues();
		for (QueueInfo q : qInfo) {
			ps.println("Queue: " + q.getQueueName() + ", Current Capacity: " + q.getCurrentCapacity() + " Max Capacity: " +
				q.getMaximumCapacity() + " Applications: " + q.getApplications().size());
		}
		return baos.toString();
	} catch (Exception e) {
		throw new RuntimeException("Couldn't get cluster description", e);
	}
}
 
Example 11
Source File: XMLSerializer.java    From vxquery with Apache License 2.0 5 votes vote down vote up
private void printDocumentNode(PrintStream ps, TaggedValuePointable tvp) {
    DocumentNodePointable dnp = pp.takeOne(DocumentNodePointable.class);
    SequencePointable seqp = pp.takeOne(SequencePointable.class);
    try {
        ps.append("<?xml version=\"1.0\"?>\n");
        tvp.getValue(dnp);
        dnp.getContent(ntp, seqp);
        printSequence(ps, seqp);
    } finally {
        pp.giveBack(seqp);
        pp.giveBack(dnp);
    }
}
 
Example 12
Source File: Constructor.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void print(PrintStream s, ParserWalker pos) {
	IteratorSTL<String> piter;
	for (piter = printpiece.begin(); !piter.isEnd(); piter.increment()) {
		if (piter.get().charAt(0) == '\n') {
			int index = piter.get().charAt(1) - 'A';
			operands.get(index).print(s, pos);
		}
		else {
			s.append(piter.get());
		}
	}
}
 
Example 13
Source File: XMLSerializer.java    From vxquery with Apache License 2.0 5 votes vote down vote up
private void printCommentNode(PrintStream ps, TaggedValuePointable tvp) {
    TextOrCommentNodePointable tcnp = pp.takeOne(TextOrCommentNodePointable.class);
    UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
    try {
        tvp.getValue(tcnp);
        tcnp.getValue(ntp, utf8sp);
        ps.append("<!--");
        printString(ps, utf8sp);
        ps.append("-->");
    } finally {
        pp.giveBack(tcnp);
        pp.giveBack(utf8sp);
    }
}
 
Example 14
Source File: RouteReloaderUnitTest.java    From xio with Apache License 2.0 5 votes vote down vote up
private String rawCreateConf(String value, String filename) throws FileNotFoundException {
  File output = new File(temporaryFolder.getRoot(), filename);
  PrintStream out = new PrintStream(output);
  out.append(value);
  out.flush();
  out.close();
  return output.getAbsolutePath();
}
 
Example 15
Source File: PlusExpression.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void saveXml(PrintStream s) {
	s.append("<plus_exp>\n");
	super.saveXml(s);
	s.append("</plus_exp>\n");
}
 
Example 16
Source File: UserOpSymbol.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
   public void saveXmlHeader( PrintStream s ) {
	s.append( "<userop_head" );
    saveSleighSymbolXmlHeader(s);
	s.println( "/>" );
}
 
Example 17
Source File: SdfStatistics.java    From rtg-tools with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Gather statistics about slim a slim data file and write to an output stream
 * @param reader sequences reader to print statistics for
 * @param dir directory for the sequences reader
 * @param out where to write statistics to
 * @param nStats whether to produce statistics on N occurrences
 * @param pStats whether to produce only statistics regarding position based N occurrences.
 * @param quality whether to output the quality score per read histogram
 * @exception IOException if an error occurs.
 */
public static void performStatistics(AnnotatedSequencesReader reader, File dir, final PrintStream out, final boolean nStats, final boolean pStats, final boolean quality) throws IOException {
  out.append("Location           : ");
  out.append(dir.getAbsolutePath());
  out.append(StringUtils.LS);
  if (reader.commandLine() != null) {
    out.append("Parameters         : ");
    out.append(reader.commandLine());
    out.append(StringUtils.LS);
  }
  if (reader.comment() != null) {
    out.append("Comment            : ");
    out.append(reader.comment());
    out.append(StringUtils.LS);
  }
  if (reader.samReadGroup() != null) {
    out.append("SAM read group     : ");
    out.append(reader.samReadGroup());
    out.append(StringUtils.LS);
  }
  out.append("SDF Version        : ");
  out.append(Long.toString(reader.sdfVersion()));
  out.append(StringUtils.LS);

  if (!pStats) {
    out.append("Type               : ");
    out.append(reader.type().toString());
    out.append(StringUtils.LS);
    out.append("Source             : ");
    out.append(reader.getPrereadType().toString());
    out.append(StringUtils.LS);
    out.append("Paired arm         : ");
    out.append(reader.getArm().toString());
    out.append(StringUtils.LS);
    final SdfId sdfId = reader.getSdfId();
    if (sdfId.available()) {
      out.append("SDF-ID             : ");
      out.append(sdfId.toString());
      out.append(StringUtils.LS);
    }
    out.append("Number of sequences: ");
    out.append(Long.toString(reader.numberSequences()));
    out.append(StringUtils.LS);
    final long max = reader.maxLength();
    final long min = reader.minLength();
    if (max >= min) {
      out.append("Maximum length     : ");
      out.append(Long.toString(max));
      out.append(StringUtils.LS);
      out.append("Minimum length     : ");
      out.append(Long.toString(min));
      out.append(StringUtils.LS);
    }
    out.append("Sequence names     : ");
    out.append(reader.hasNames() ? "yes" : "no");
    out.append(StringUtils.LS);
    out.append("Sex metadata       : ");
    out.append(ReferenceGenome.hasReferenceFile(reader) ? "yes" : "no");
    out.append(StringUtils.LS);
    out.append("Taxonomy metadata  : ");
    out.append(TaxonomyUtils.hasTaxonomyInfo(reader) ? "yes" : "no");
    out.append(StringUtils.LS);
    final long[] counts = reader.residueCounts();
    long sum = 0;
    for (int i = 0 ; i < counts.length; ++i) {
      out.append((reader.type() == SequenceType.DNA) ? DNA.values()[i].toString() : Protein.values()[i].toString());
      out.append("                  : ");
      out.append(Long.toString(counts[i]));
      out.append(StringUtils.LS);
      sum += counts[i];
    }
    out.append("Total residues     : ");
    out.append(Long.toString(sum));
    out.append(StringUtils.LS);
    if (quality) {
      printQualityHistogram(reader, out);
    }
    out.append("Residue qualities  : ");
    out.append(reader.hasQualityData() && reader.hasHistogram() ? "yes" : "no");
    out.append(StringUtils.LS);
    if (nStats) {
      printNBlocks(reader, out);
    }
    out.append(StringUtils.LS);
  } else {
    printPositionBlock(reader, out);
  }
  printReadMe(reader, out);
}
 
Example 18
Source File: MultExpression.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void saveXml(PrintStream s) {
	s.append("<mult_exp>\n");
	super.saveXml(s);
	s.append("</mult_exp>\n");
}
 
Example 19
Source File: FlowRefSymbol.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void print(PrintStream s, ParserWalker pos) {
	long val = pos.getFlowRefAddr().getOffset();
	s.append("0x");
	s.print(Long.toHexString(val));
}
 
Example 20
Source File: DocumentationPrinter.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
private static void writePermissionsWikiTable()
            throws IOException {
        try (FileOutputStream fos = new FileOutputStream("wiki_permissions.md")) {
            PrintStream stream = new PrintStream(fos);

            stream.print("## Overview\n");
            stream.print("This page is generated from the source. " +
                    "Click one of the edit buttons below to modify a command class. " +
                    "You will need to find the parts which correspond to the documentation. " +
                    "Command documentation will be consistent with what is available ingame");
            stream.println();
            stream.println();
            stream.print("To view this information ingame use `//help [category|command]`\n");
            stream.print("## Command Syntax     \n");
            stream.print(" - `<arg>` - A required parameter     \n");
            stream.print(" - `[arg]` - An optional parameter     \n");
            stream.print(" - `<arg1|arg2>` - Multiple parameters options     \n");
            stream.print(" - `<arg=value>` - Default or suggested value     \n");
            stream.print(" - `-a` - A command flag e.g. `//<command> -a [flag-value]`");
            stream.println();
            stream.print("## See also\n");
            stream.print(" - [Masks](https://github.com/boy0001/FastAsyncWorldedit/wiki/WorldEdit---FAWE-mask-list)\n");
            stream.print(" - [Patterns](https://github.com/boy0001/FastAsyncWorldedit/wiki/WorldEdit-and-FAWE-patterns)\n");
            stream.print(" - [Transforms](https://github.com/boy0001/FastAsyncWorldedit/wiki/Transforms)\n");
            stream.println();
            stream.print("## Content");
            stream.println();
            stream.print("Click on a category to go to the list of commands, or `More Info` for detailed descriptions ");
            stream.println();
            StringBuilder builder = new StringBuilder();
            writePermissionsWikiTable(stream, builder, "/we ", WorldEditCommands.class);
            writePermissionsWikiTable(stream, builder, "/", UtilityCommands.class);
            writePermissionsWikiTable(stream, builder, "/", RegionCommands.class);
            writePermissionsWikiTable(stream, builder, "/", SelectionCommands.class);
            writePermissionsWikiTable(stream, builder, "/", HistoryCommands.class);
            writePermissionsWikiTable(stream, builder, "/schematic ", SchematicCommands.class);
            writePermissionsWikiTable(stream, builder, "/", ClipboardCommands.class);
            writePermissionsWikiTable(stream, builder, "/", GenerationCommands.class);
            writePermissionsWikiTable(stream, builder, "/", BiomeCommands.class);
            writePermissionsWikiTable(stream, builder, "/anvil ", AnvilCommands.class);
            writePermissionsWikiTable(stream, builder, "/sp ", SuperPickaxeCommands.class);
            writePermissionsWikiTable(stream, builder, "/", NavigationCommands.class);
            writePermissionsWikiTable(stream, builder, "/snapshot", SnapshotCommands.class);
            writePermissionsWikiTable(stream, builder, "/", SnapshotUtilCommands.class);
            writePermissionsWikiTable(stream, builder, "/", ScriptingCommands.class);
            writePermissionsWikiTable(stream, builder, "/", ChunkCommands.class);
            writePermissionsWikiTable(stream, builder, "/", OptionsCommands.class);
            writePermissionsWikiTable(stream, builder, "/", BrushOptionsCommands.class);
            writePermissionsWikiTable(stream, builder, "/tool ", ToolCommands.class);
            writePermissionsWikiTable(stream, builder, "/brush ", BrushCommands.class);
            writePermissionsWikiTable(stream, builder, "", MaskCommands.class, "/Masks");
            writePermissionsWikiTable(stream, builder, "", PatternCommands.class, "/Patterns");
            writePermissionsWikiTable(stream, builder, "", TransformCommands.class, "/Transforms");
            writePermissionsWikiTable(stream, builder, "/cfi ", CFICommands.class, "Create From Image");
            stream.println();
            stream.print("#### Uncategorized\n");
            stream.append("| Aliases | Permission | flags | Usage |\n");
            stream.append("| --- | --- | --- | --- |\n");
            stream.append("| //cancel | fawe.cancel | | Cancels your current operations |\n");
            stream.append("| /plot replaceall | plots.replaceall | | Replace all blocks in the plot world |\n");
//            stream.append("| /plot createfromimage | plots.createfromimage | | Starts world creation from a heightmap image: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/CreateFromImage) |\n");
            stream.print("\n---\n");

            stream.print(builder);
        }
    }