当前位置: 首页>>代码示例>>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;未经允许,请勿转载。