當前位置: 首頁>>代碼示例>>Java>>正文


Java PrintWriter.printf方法代碼示例

本文整理匯總了Java中java.io.PrintWriter.printf方法的典型用法代碼示例。如果您正苦於以下問題:Java PrintWriter.printf方法的具體用法?Java PrintWriter.printf怎麽用?Java PrintWriter.printf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.PrintWriter的用法示例。


在下文中一共展示了PrintWriter.printf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displayJobList

import java.io.PrintWriter; //導入方法依賴的package包/類
@Private
public void displayJobList(JobStatus[] jobs, PrintWriter writer) {
  writer.println("Total jobs:" + jobs.length);
  writer.printf(headerPattern, "JobId", "State", "StartTime", "UserName",
    "Queue", "Priority", "UsedContainers",
    "RsvdContainers", "UsedMem", "RsvdMem", "NeededMem", "AM info");
  for (JobStatus job : jobs) {
    int numUsedSlots = job.getNumUsedSlots();
    int numReservedSlots = job.getNumReservedSlots();
    int usedMem = job.getUsedMem();
    int rsvdMem = job.getReservedMem();
    int neededMem = job.getNeededMem();
    writer.printf(dataPattern,
        job.getJobID().toString(), job.getState(), job.getStartTime(),
        job.getUsername(), job.getQueue(), 
        job.getPriority().name(),
        numUsedSlots < 0 ? UNAVAILABLE : numUsedSlots,
        numReservedSlots < 0 ? UNAVAILABLE : numReservedSlots,
        usedMem < 0 ? UNAVAILABLE : String.format(memPattern, usedMem),
        rsvdMem < 0 ? UNAVAILABLE : String.format(memPattern, rsvdMem),
        neededMem < 0 ? UNAVAILABLE : String.format(memPattern, neededMem),
        job.getSchedulingInfo());
  }
  writer.flush();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:CLI.java

示例2: main

import java.io.PrintWriter; //導入方法依賴的package包/類
public static void main(String[] args) {
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
    Scanner x = new Scanner(System.in);
    short n = x.nextShort();
    double s = 0;
    for (int i = 0; i < n; i++) {
        s += x.nextInt();
    }
    writer.printf("%.6f", s / n);
    writer.close();
}
 
開發者ID:bakhodirsbox,項目名稱:AlgoCS,代碼行數:12,代碼來源:HeatingMain_1457.java

示例3: getPatternActions

import java.io.PrintWriter; //導入方法依賴的package包/類
private List<PatternAction> getPatternActions(PrintWriter log,
                                              Properties p, String key) {
    String[] tools = getTools(log, p, key);
    List<PatternAction> result = new ArrayList<>(tools.length);
    for (String tool : tools) {
        try {
            PatternAction action = new PatternAction(
                    Utils.prependPrefix(name, tool), tool, p);
            result.add(action);
        } catch (Exception e) {
            log.printf("ERROR: %s cannot be created : %s %n",
                    tool, e.getMessage());
            e.printStackTrace(log);
        }
    }
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:ActionSet.java

示例4: getSimpleActions

import java.io.PrintWriter; //導入方法依賴的package包/類
private List<SimpleAction> getSimpleActions(PrintWriter log, Properties p,
                                            String key) {
    String[] tools = getTools(log, p, key);
    List<SimpleAction> result = new ArrayList<>(tools.length);
    for (String tool : tools) {
        try {
            SimpleAction action = new SimpleAction(
                    Utils.prependPrefix(name, tool), tool, p);
            result.add(action);
        } catch (Exception e) {
            log.printf("ERROR: %s cannot be created : %s %n",
                    tool, e.getMessage());
            e.printStackTrace(log);
        }
    }
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:ActionSet.java

示例5: createImports

import java.io.PrintWriter; //導入方法依賴的package包/類
protected static void createImports(PrintWriter out, List<GeneratedPlugin> plugins) {
    out.printf("import jdk.vm.ci.meta.ResolvedJavaMethod;\n");
    out.printf("import org.graalvm.compiler.serviceprovider.ServiceProvider;\n");
    out.printf("\n");
    out.printf("import org.graalvm.compiler.nodes.ValueNode;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedInvocationPlugin;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory;\n");

    HashSet<String> extra = new HashSet<>();
    for (GeneratedPlugin plugin : plugins) {
        plugin.extraImports(extra);
    }
    if (!extra.isEmpty()) {
        out.printf("\n");
        for (String i : extra) {
            out.printf("import %s;\n", i);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:PluginGenerator.java

示例6: printHeader

import java.io.PrintWriter; //導入方法依賴的package包/類
private void printHeader(PrintWriter out, String nodeName) {
  out.print("<html><head>");
  out.printf("<title>%s Reconfiguration Utility</title>%n",
             StringEscapeUtils.escapeHtml(nodeName));
  out.print("</head><body>\n");
  out.printf("<h1>%s Reconfiguration Utility</h1>%n",
             StringEscapeUtils.escapeHtml(nodeName));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:9,代碼來源:ReconfigurationServlet.java

示例7: register

import java.io.PrintWriter; //導入方法依賴的package包/類
public void register(PrintWriter out) {
    out.printf("        plugins.register(new %s(", pluginName);
    if (needInjectionProvider) {
        out.printf("injection");
    }
    out.printf("), %s.class, \"%s\"", intrinsicMethod.getEnclosingElement(), intrinsicMethod.getSimpleName());
    if (!intrinsicMethod.getModifiers().contains(Modifier.STATIC)) {
        out.printf(", InvocationPlugin.Receiver.class");
    }
    for (VariableElement arg : intrinsicMethod.getParameters()) {
        out.printf(", %s.class", getErasedType(arg.asType()));
    }
    out.printf(");\n");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:GeneratedPlugin.java

示例8: printFreqs

import java.io.PrintWriter; //導入方法依賴的package包/類
private void printFreqs(PrintWriter out, String label) {
    int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
    for (int i = 0; i + k <= label.length(); i++) {
        String kmer = label.substring(i, i + k);
        int freq = subgraph.get(kmer);
        min = Math.min(min, freq);
        max = Math.max(max, freq);
    }
    out.printf(":%d:%d", min, max);
}
 
開發者ID:ctlab,項目名稱:metacherchant,代碼行數:11,代碼來源:GraphvizWriter.java

示例9: generate

import java.io.PrintWriter; //導入方法依賴的package包/類
public void generate(ProcessingEnvironment env, PrintWriter out) {
    out.printf("    //        class: %s\n", intrinsicMethod.getEnclosingElement());
    out.printf("    //       method: %s\n", intrinsicMethod);
    out.printf("    // generated-by: %s\n", getClass().getName());
    out.printf("    private static final class %s extends GeneratedInvocationPlugin {\n", pluginName);
    out.printf("\n");
    out.printf("        @Override\n");
    out.printf("        public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {\n");
    InjectedDependencies deps = createExecute(env, out);
    out.printf("        }\n");

    createPrivateMembers(out, deps);

    out.printf("    }\n");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:GeneratedPlugin.java

示例10: prepareProcess

import java.io.PrintWriter; //導入方法依賴的package包/類
public ProcessBuilder prepareProcess(PrintWriter log, String app,
                                     String... args) {
    File appBin = findApp(app);
    if (appBin == null) {
        log.printf("ERROR: can't find %s in %s.%n",
                app, Arrays.toString(paths));
        return null;
    }
    List<String> command = new ArrayList<>(args.length + 1);
    command.add(appBin.toString());
    Collections.addAll(command, args);
    return new ProcessBuilder()
            .command(command)
            .directory(workDir.toFile());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:ActionHelper.java

示例11: runGatherer

import java.io.PrintWriter; //導入方法依賴的package包/類
private void runGatherer(String name, Path workDir, PrintWriter log,
                         PrintWriter out, long pid) {
    try (HtmlPage html = new HtmlPage(out)) {
        ProcessInfoGatherer gatherer = new GathererFactory(
                OS.current().family,
                workDir, log, testJdk.toPath()).getProcessInfoGatherer();
        try (ElapsedTimePrinter timePrinter
                     = new ElapsedTimePrinter(new Stopwatch(), name, log)) {
            gatherer.gatherProcessInfo(html.getRootSection(), pid);
        }
    } catch (Throwable e) {
        log.printf("ERROR: exception in timeout handler %s:", name);
        e.printStackTrace(log);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:GatherProcessInfoTimeoutHandler.java

示例12: print

import java.io.PrintWriter; //導入方法依賴的package包/類
void print(PrintWriter writer, String indent, boolean printChildren) {
  writer.printf("%s%s %s [%s] version %d%n", indent, type, name, fullPath(), getVersion());
  if (printChildren) {
    for (Node child : children) {
      child.print(writer, indent + "  ", true);
    }
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:9,代碼來源:Node.java

示例13: printEntry

import java.io.PrintWriter; //導入方法依賴的package包/類
static void printEntry(PrintWriter pw, String reasonClaimWarrantId, String w0, String w1,
        Integer correctLabelW0orW1, String reasonGist, String annotatedStance, String title,
        String description)
{
    pw.printf(Locale.ENGLISH, "%s\t%s\t%s\t%d\t%s\t%s\t%s\t%s%n", reasonClaimWarrantId, w0, w1,
            correctLabelW0orW1, reasonGist, annotatedStance, title, description);
}
 
開發者ID:UKPLab,項目名稱:argument-reasoning-comprehension-task,代碼行數:8,代碼來源:Step9aFinalDataProvider.java

示例14: writeFile

import java.io.PrintWriter; //導入方法依賴的package包/類
public static void writeFile(String[] words, File file) throws IOException {
	PrintWriter hp = new PrintWriter(file);
	
	for (int i = 0; i < words.length; i++){
		hp.printf("%s\n", words[i]);
	}
	
	hp.close();
}
 
開發者ID:ZePaiva,項目名稱:Prog2,代碼行數:10,代碼來源:E905.java

示例15: prepareCrashReport

import java.io.PrintWriter; //導入方法依賴的package包/類
/** This method prepares the crash report. */
private static String prepareCrashReport (Thread thread, Throwable ex, String email, String problem) {
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
   pw.printf("Alloy Analyzer %s crash report (Build Date = %s)\n", Version.version(), Version.buildDate());
   pw.printf("\n========================= Email ============================\n%s\n", Util.convertLineBreak(email).trim());
   pw.printf("\n========================= Problem ==========================\n%s\n", Util.convertLineBreak(problem).trim());
   pw.printf("\n========================= Thread Name ======================\n%s\n", thread.getName().trim());
   if (ex!=null) pw.printf("\n========================= Stack Trace ======================\n%s\n", dump(ex));
   pw.printf("\n========================= Preferences ======================\n");
   try {
      for(String key: Preferences.userNodeForPackage(Util.class).keys()) {
         String value = Preferences.userNodeForPackage(Util.class).get(key, "");
         pw.printf("%s = %s\n", key.trim(), value.trim());
      }
   } catch(BackingStoreException bse) {
      pw.printf("BackingStoreException occurred: %s\n", bse.toString().trim());
   }
   pw.printf("\n========================= System Properties ================\n");
   pw.println("Runtime.freeMemory() = " + Runtime.getRuntime().freeMemory());
   pw.println("nRuntime.totalMemory() = " + Runtime.getRuntime().totalMemory());
   for(Map.Entry<Object,Object> e: System.getProperties().entrySet()) {
      String k = String.valueOf(e.getKey()), v = String.valueOf(e.getValue());
      pw.printf("%s = %s\n", k.trim(), v.trim());
   }
   pw.printf("\n========================= The End ==========================\n\n");
   pw.close();
   sw.flush();
   return sw.toString();
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:31,代碼來源:MailBug.java


注:本文中的java.io.PrintWriter.printf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。