Java Code Examples for java.io.PrintStream#printf()
The following examples show how to use
java.io.PrintStream#printf() .
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: CodeStatistics.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Prints out the collected statistics. * * @param out {@code non-null;} where to output to */ public void dumpStatistics(PrintStream out) { out.printf("Optimizer Delta Rop Insns: %d total: %d " + "(%.2f%%) Delta Registers: %d\n", runningDeltaInsns, runningTotalInsns, (100.0 * (((float) runningDeltaInsns) / (runningTotalInsns + Math.abs(runningDeltaInsns)))), runningDeltaRegisters); out.printf("Optimizer Delta Dex Insns: Insns: %d total: %d " + "(%.2f%%) Delta Registers: %d\n", dexRunningDeltaInsns, dexRunningTotalInsns, (100.0 * (((float) dexRunningDeltaInsns) / (dexRunningTotalInsns + Math.abs(dexRunningDeltaInsns)))), dexRunningDeltaRegisters); out.printf("Original bytecode byte count: %d\n", runningOriginalBytes); }
Example 2
Source File: Synth.java From log-synth with Apache License 2.0 | 6 votes |
private static void printDelimited(Quote quoteConvention, List<String> names, JsonNode fields, String separator, PrintStream out) { String x = ""; for (String name : names) { switch (quoteConvention) { case DOUBLE_QUOTE: out.printf("%s%s", x, fields.get(name)); break; case OPTIMISTIC: out.printf("%s%s", x, fields.get(name).asText()); break; case BACK_SLASH: out.printf("%s%s", x, fields.get(name).asText().replaceAll("([,\t\\s\\\\])", "\\\\$1")); break; } x = separator; } out.print("\n"); }
Example 3
Source File: RemoteMeasurements.java From netbeans with Apache License 2.0 | 6 votes |
private void dumpCategoriesStatistics(PrintStream out) { long totalTime = 0; long totalTraffic = 0; HashMap<String, Counters> map = new HashMap<>(); for (Stat stat : stats.values()) { Counters counters = map.get(stat.category); if (counters == null) { counters = new Counters(); map.put(stat.category, counters); } counters.add(stat); } out.printf("== Categories stat begin ==\n"); // NOI18N out.printf("%20s|%8s|%8s|%10s|%s\n", "Category", "Count", "Time", "~Traffic", "Args"); // NOI18N for (Map.Entry<String, Counters> entry : map.entrySet()) { long dt = entry.getValue().time.get(); long supposedTraffic = entry.getValue().supposedTraffic.get(); out.printf("%20s|%8d|%8d|%s\n", entry.getKey(), entry.getValue().count.get(), dt, supposedTraffic, entry.getValue().args.size()); // NOI18N totalTime += dt; } out.printf("== Categories stat end ==\n"); // NOI18N out.printf("Total time by all categories [ms]: %20d\n", totalTime); // NOI18N out.printf("Total supposed traffic by all categories [bytes]: %20d\n", totalTraffic); // NOI18N }
Example 4
Source File: UsabilityChrono.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Print a month calendar with complete week rows. * @param date A date in some calendar * @param out a PrintStream */ private static void printMonthCal(ChronoLocalDate date, PrintStream out) { int lengthOfMonth = (int) date.lengthOfMonth(); ChronoLocalDate end = date.with(ChronoField.DAY_OF_MONTH, lengthOfMonth); end = end.plus(7 - end.get(ChronoField.DAY_OF_WEEK), ChronoUnit.DAYS); // Back up to the beginning of the week including the 1st of the month ChronoLocalDate start = date.with(ChronoField.DAY_OF_MONTH, 1); start = start.minus(start.get(ChronoField.DAY_OF_WEEK), ChronoUnit.DAYS); out.printf("%9s Month %2d, %4d%n", date.getChronology().getId(), date.get(ChronoField.MONTH_OF_YEAR), date.get(ChronoField.YEAR)); String[] colText = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; printMonthRow(colText, " ", out); String[] cell = new String[7]; for ( ; start.compareTo(end) <= 0; start = start.plus(1, ChronoUnit.DAYS)) { int ndx = start.get(ChronoField.DAY_OF_WEEK) - 1; cell[ndx] = Integer.toString((int) start.get(ChronoField.DAY_OF_MONTH)); if (ndx == 6) { printMonthRow(cell, "|", out); } } }
Example 5
Source File: HostRegisterCommand.java From helios with Apache License 2.0 | 6 votes |
@Override int run(final Namespace options, final HeliosClient client, PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final String host = options.getString(hostArg.getDest()); final String id = options.getString(idArg.getDest()); if (isNullOrEmpty(host) || isNullOrEmpty(id)) { out.print("You must specify the hostname and id."); return 1; } out.printf("Registering host %s with id %s%n", host, id); int code = 0; out.printf("%s: ", host); final int result = client.registerHost(host, id).get(); if (result == 200) { out.printf("done%n"); } else { out.printf("failed: %s%n", result); code = 1; } return code; }
Example 6
Source File: AuditRulesCommand.java From buck with Apache License 2.0 | 5 votes |
private static void printRuleAsPythonToStdout(PrintStream out, Map<String, Object> rawRule) { String type = (String) rawRule.get(BuckPyFunction.TYPE_PROPERTY_NAME); out.printf("%s(\n", type); // The properties in the order they should be displayed for this rule. LinkedHashSet<String> properties = new LinkedHashSet<>(); // Always display the "name" property first. properties.add("name"); // Add the properties specific to the rule. SortedSet<String> customProperties = new TreeSet<>(); for (String key : rawRule.keySet()) { // Ignore keys that start with "buck.". if (!(key.startsWith(BuckPyFunction.INTERNAL_PROPERTY_NAME_PREFIX) || LAST_PROPERTIES.contains(key))) { customProperties.add(key); } } properties.addAll(customProperties); // Add common properties that should be displayed last. properties.addAll(Sets.intersection(LAST_PROPERTIES, rawRule.keySet())); // Write out the properties and their corresponding values. for (String property : properties) { Object rawValue = rawRule.get(property); if (!shouldInclude(rawValue)) { continue; } String displayValue = createDisplayString(INDENT, rawValue); out.printf("%s%s = %s,\n", INDENT, formatAttribute(property), displayValue); } // Close the rule definition. out.print(")\n\n"); }
Example 7
Source File: InlineTree.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void printImpl(PrintStream st, int indent) { for (int i = 0; i < indent; i++) st.print(" "); st.printf(" @ %d ", callerBci()); method().printShortName(st); st.println(); GrowableArray<InlineTree> subt = subtrees(); for (int i = 0 ; i < subt.length(); i++) { subt.at(i).printImpl(st, indent + 2); } }
Example 8
Source File: HtmlExporter.java From Design-Patterns-and-SOLID-Principles-with-Java with MIT License | 5 votes |
@Override protected void handleRecord(PrintStream out, List<Report.Field> record, boolean first, boolean last) { out.println("\t\t<tr>"); for (Report.Field field : record) { out.printf("\t\t\t<td>%s</td>%n", field.getAsString()); } out.println("\t\t</tr>"); }
Example 9
Source File: ReportingTaskResult.java From nifi with Apache License 2.0 | 5 votes |
@Override protected void writeSimpleResult(final PrintStream output) throws IOException { final ReportingTaskDTO reportingTaskDTO = reportingTaskEntity.getComponent(); final BundleDTO bundle = reportingTaskDTO.getBundle(); output.printf("Name : %s\nID : %s\nType : %s\nBundle: %s - %s %s\nState : %s\n", reportingTaskDTO.getName(), reportingTaskDTO.getId(), reportingTaskDTO.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion(), reportingTaskDTO.getState()); }
Example 10
Source File: InlineTree.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void printImpl(PrintStream st, int indent) { for (int i = 0; i < indent; i++) st.print(" "); st.printf(" @ %d ", callerBci()); method().printShortName(st); st.println(); GrowableArray<InlineTree> subt = subtrees(); for (int i = 0 ; i < subt.length(); i++) { subt.at(i).printImpl(st, indent + 2); } }
Example 11
Source File: HtmlExporter.java From Design-Patterns-and-SOLID-Principles-with-Java with MIT License | 5 votes |
@Override protected void handleLabels(PrintStream out, List<String> labels) { out.println("\t\t<tr>"); for (String label : labels) { out.printf("\t\t\t<td>%s</td>%n", label); } out.println("\t\t</tr>"); }
Example 12
Source File: MachCallStaticJavaNode.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void dumpSpec(PrintStream st) { st.print("Static "); String n = name(); if (n != null) { st.printf("wrapper for: %s", n); // dump_trap_args(st); st.print(" "); } super.dumpSpec(st); }
Example 13
Source File: InlineTree.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void dumpReplayData(PrintStream out) { out.printf(" %d %d ", inlineLevel(), callerBci()); Method method = (Method)method().getMetadata(); Klass holder = method.getMethodHolder(); out.print(holder.getName().asString() + " " + OopUtilities.escapeString(method.getName().asString()) + " " + method.getSignature().asString()); GrowableArray<InlineTree> subt = subtrees(); for (int i = 0 ; i < subt.length(); i++) { subt.at(i).dumpReplayData(out); } }
Example 14
Source File: InlineTree.java From hottub with GNU General Public License v2.0 | 5 votes |
public void dumpReplayData(PrintStream out) { out.printf(" %d %d ", inlineLevel(), callerBci()); Method method = (Method)method().getMetadata(); Klass holder = method.getMethodHolder(); out.print(holder.getName().asString() + " " + OopUtilities.escapeString(method.getName().asString()) + " " + method.getSignature().asString()); GrowableArray<InlineTree> subt = subtrees(); for (int i = 0 ; i < subt.length(); i++) { subt.at(i).dumpReplayData(out); } }
Example 15
Source File: Debug.java From tomee with Apache License 2.0 | 5 votes |
private void printTxt(final Set<Node> seen, final PrintStream out, final Node node, String s) { if (!seen.add(node)) { return; } out.print(s); final StackTraceElement e = node.getElement(); out.printf("**%s** *%s* (%s)\n", e.getMethodName(), reverse(e.getClassName()), e.getLineNumber()); s = " " + s; for (final Node child : node.children) { print(seen, out, child, s); } }
Example 16
Source File: MakeNotEntrantEvent.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void print(PrintStream stream) { if (isZombie()) { stream.printf("%s make_zombie\n", getId()); } else { stream.printf("%s make_not_entrant\n", getId()); } }
Example 17
Source File: LogParser.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public void print(PrintStream stream) { stream.printf("%s %s %s %s %.3f ", getId(), tagName, kind, classId, getStart()); stream.print(jvms.toString()); stream.print("\n"); }
Example 18
Source File: Detect.java From java-docs-samples with Apache License 2.0 | 4 votes |
/** * Performs handwritten text detection on a remote image on Google Cloud Storage. * * @param gcsPath The path to the remote file on Google Cloud Storage to detect handwritten text * on. * @param out A {@link PrintStream} to write the results to. * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ public static void detectHandwrittenOcrGcs(String gcsPath, PrintStream out) throws Exception { List<AnnotateImageRequest> requests = new ArrayList<>(); ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build(); Image img = Image.newBuilder().setSource(imgSource).build(); Feature feat = Feature.newBuilder().setType(Type.DOCUMENT_TEXT_DETECTION).build(); // Set the parameters for the image ImageContext imageContext = ImageContext.newBuilder().addLanguageHints("en-t-i0-handwrit").build(); AnnotateImageRequest request = AnnotateImageRequest.newBuilder() .addFeatures(feat) .setImage(img) .setImageContext(imageContext) .build(); requests.add(request); try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) { BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests); List<AnnotateImageResponse> responses = response.getResponsesList(); client.close(); for (AnnotateImageResponse res : responses) { if (res.hasError()) { out.printf("Error: %s\n", res.getError().getMessage()); return; } // For full list of available annotations, see http://g.co/cloud/vision/docs TextAnnotation annotation = res.getFullTextAnnotation(); for (Page page : annotation.getPagesList()) { String pageText = ""; for (Block block : page.getBlocksList()) { String blockText = ""; for (Paragraph para : block.getParagraphsList()) { String paraText = ""; for (Word word : para.getWordsList()) { String wordText = ""; for (Symbol symbol : word.getSymbolsList()) { wordText = wordText + symbol.getText(); out.format( "Symbol text: %s (confidence: %f)\n", symbol.getText(), symbol.getConfidence()); } out.format("Word text: %s (confidence: %f)\n\n", wordText, word.getConfidence()); paraText = String.format("%s %s", paraText, wordText); } // Output Example using Paragraph: out.println("\nParagraph: \n" + paraText); out.format("Paragraph Confidence: %f\n", para.getConfidence()); blockText = blockText + paraText; } pageText = pageText + blockText; } } out.println("\nComplete annotation:"); out.println(annotation.getText()); } } }
Example 19
Source File: JobUndeployCommand.java From helios with Apache License 2.0 | 4 votes |
@Override protected int runWithJob(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final Job job, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final JobId jobId = job.getId(); final boolean all = options.getBoolean(allArg.getDest()); final boolean yes = options.getBoolean(yesArg.getDest()); final List<String> hosts; if (all) { final JobStatus status = client.jobStatus(jobId).get(); hosts = ImmutableList.copyOf(status.getDeployments().keySet()); if (hosts.isEmpty()) { out.printf("%s is not currently deployed on any hosts.", jobId); return 0; } if (!yes) { out.printf("This will undeploy %s from %s%n", jobId, hosts); final boolean confirmed = Utils.userConfirmed(out, stdin); if (!confirmed) { return 1; } } } else { hosts = options.getList(hostsArg.getDest()); if (hosts.isEmpty()) { out.println("Please either specify a list of hosts or use the -a/--all flag."); return 1; } } if (!json) { out.printf("Undeploying %s from %s%n", jobId, hosts); } int code = 0; final HostResolver resolver = HostResolver.create(client); for (final String candidateHost : hosts) { final String host = resolver.resolveName(candidateHost); if (!json) { out.printf("%s: ", host); } final String token = options.getString(tokenArg.getDest()); final JobUndeployResponse response = client.undeploy(jobId, host, token).get(); if (response.getStatus() == JobUndeployResponse.Status.OK) { if (!json) { out.println("done"); } else { out.print(response.toJsonString()); } } else { if (!json) { out.println("failed: " + response); } else { out.print(response.toJsonString()); } code = -1; } } return code; }
Example 20
Source File: CSVUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static PrintStream println(PrintStream out, char separator, char quote, char escape, String format, Object... args) { out.printf(format, escapeArgs(separator, quote, escape, args)); out.println(); return out; }