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


Java PrintWriter.format方法代碼示例

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


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

示例1: printStackTrace

import java.io.PrintWriter; //導入方法依賴的package包/類
@Override
public void printStackTrace(PrintWriter printWriter) {
    if (causes.size() <= 1) {
        super.printStackTrace(printWriter);
        return;
    }

    hideCause.set(true);
    try {
        super.printStackTrace(printWriter);
        for (int i = 0; i < causes.size(); i++) {
            Throwable cause = causes.get(i);
            printWriter.format("Cause %s: ", i + 1);
            cause.printStackTrace(printWriter);
        }
    } finally {
        hideCause.set(false);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:20,代碼來源:DefaultMultiCauseException.java

示例2: printHelp0

import java.io.PrintWriter; //導入方法依賴的package包/類
private static void printHelp0(PrintWriter out, boolean printExtra) {
    out.format("%s%n", Main.getMsg("main.help.preopt"));
    for (OptionType type : OptionType.values()) {
        boolean typeHeadingWritten = false;

        for (Option o : recognizedOptions) {
            if (!o.type.equals(type))
                continue;
            String name = o.aliases[0].substring(1); // there must always be at least one name
            name = name.charAt(0) == '-' ? name.substring(1) : name;
            if (o.isHidden() || name.equals("h")) {
                continue;
            }
            if (o.isExtra() && !printExtra) {
                continue;
            }
            if (!typeHeadingWritten) {
                out.format("%n%s%n", Main.getMsg("main.help.opt." + type.name));
                typeHeadingWritten = true;
            }
            out.format("%s%n", Main.getMsg("main.help.opt." + type.name + "." + name));
        }
    }
    out.format("%n%s%n%n", Main.getMsg("main.help.postopt"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:GNUStyleOptions.java

示例3: printNode

import java.io.PrintWriter; //導入方法依賴的package包/類
private void printNode(Node node, Writer writer) {
    final PrintWriter printWriter = new PrintWriter(writer);
    if (GUtil.isTrue(publicId)) {
        printWriter.format("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">%n", node.name(), publicId, systemId);
    }
    IndentPrinter indentPrinter = new IndentPrinter(printWriter, indentation) {
        @Override
        public void println() {
            printWriter.println();
        }
    };
    XmlNodePrinter nodePrinter = new XmlNodePrinter(indentPrinter);
    nodePrinter.setPreserveWhitespace(true);
    nodePrinter.print(node);
    printWriter.flush();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:17,代碼來源:XmlTransformer.java

示例4: write

import java.io.PrintWriter; //導入方法依賴的package包/類
private void write(PrintWriter out, ClassMapping classMapping, int depth) throws IOException {
	if (classMapping.getDeobfName() == null) {
		out.format("%sCLASS %s\n", getIndent(depth), classMapping.getObfFullName());
	} else {
		out.format("%sCLASS %s %s\n", getIndent(depth), classMapping.getObfFullName(), classMapping.getDeobfName());
	}
	
	for (ClassMapping innerClassMapping : sorted(classMapping.innerClasses())) {
		write(out, innerClassMapping, depth + 1);
	}
	
	for (FieldMapping fieldMapping : sorted(classMapping.fields())) {
		write(out, fieldMapping, depth + 1);
	}
	
	for (MethodMapping methodMapping : sorted(classMapping.methods())) {
		write(out, methodMapping, depth + 1);
	}
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:20,代碼來源:MappingsWriter.java

示例5: printModuleDescriptor

import java.io.PrintWriter; //導入方法依賴的package包/類
private void printModuleDescriptor(PrintWriter out, Module module) {
    ModuleDescriptor descriptor = module.descriptor();
    out.format("%s (%s)%n", descriptor.name(), module.location());

    if (descriptor.name().equals(JAVA_BASE))
        return;

    out.println("  [Module descriptor]");
    descriptor.requires()
        .stream()
        .sorted(Comparator.comparing(ModuleDescriptor.Requires::name))
        .forEach(req -> out.format("    requires %s;%n", req));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:ModuleAnalyzer.java

示例6: testFormatUnsafe

import java.io.PrintWriter; //導入方法依賴的package包/類
public void testFormatUnsafe(PrintWriter pw, String input1,HttpServletRequest req) {
    pw.format(req.getLocale(), "%s", input1);
    pw.format("%s", input1);
    pw.format("%s %s", "SAFE", input1);
    pw.format("%s %s %s", "SAFE", "SAFE", input1);
    pw.format("%s %s %s %s", "SAFE", "SAFE", input1, "SAFE");
    pw.format(input1, "<== the actual format string can be alter");
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:9,代碼來源:XssServlet5.java

示例7: writeFields

import java.io.PrintWriter; //導入方法依賴的package包/類
private void writeFields(PrintWriter pw, String fieldType, Collection<ViewFieldType> fields) throws IOException {
  if (!fields.isEmpty()) {
    pw.format("  %s ", fieldType);

    Joiner.on(", ").appendTo(pw, Iterables.transform(fields, FIELD_TO_NAME));
    pw.println();
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:9,代碼來源:QlikAppMessageBodyGenerator.java

示例8: field

import java.io.PrintWriter; //導入方法依賴的package包/類
private static void field(PrintWriter out, String name, Object value) {
    out.format("%s: %s%n", name, value);
}
 
開發者ID:openmicroscopy,項目名稱:omero-ms-queue,代碼行數:4,代碼來源:ImportOutputFormatter.java

示例9: printNode

import java.io.PrintWriter; //導入方法依賴的package包/類
public void printNode(PrintWriter out, String node, String color, String group) {
    out.format("  \"%s\" [fontcolor=\"%s\", group=%s];%n",
               node, color, group);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:ModuleDotGraph.java

示例10: DotFileFormatter

import java.io.PrintWriter; //導入方法依賴的package包/類
DotFileFormatter(PrintWriter writer, Archive archive) {
    this.writer = writer;
    this.name = archive.getName();
    writer.format("digraph \"%s\" {%n", name);
    writer.format("    // Path: %s%n", archive.getPathName());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:JdepsWriter.java

示例11: SummaryDotFile

import java.io.PrintWriter; //導入方法依賴的package包/類
SummaryDotFile(PrintWriter writer, Analyzer.Type type) {
    this.writer = writer;
    this.type = type;
    writer.format("digraph \"summary\" {%n");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:JdepsWriter.java

示例12: printModuleInfo

import java.io.PrintWriter; //導入方法依賴的package包/類
private void printModuleInfo(PrintWriter writer, ModuleDescriptor md) {
    writer.format("%smodule %s {%n", open ? "open " : "", md.name());

    Map<String, Module> modules = configuration.getModules();

    // first print requires
    Set<Requires> reqs = md.requires().stream()
        .filter(req -> !req.name().equals("java.base") && req.modifiers().isEmpty())
        .collect(Collectors.toSet());
    reqs.stream()
        .sorted(Comparator.comparing(Requires::name))
        .forEach(req -> writer.format("    requires %s;%n",
                                      toString(req.modifiers(), req.name())));
    if (!reqs.isEmpty()) {
        writer.println();
    }

    // requires transitive
    reqs = md.requires().stream()
             .filter(req -> !req.name().equals("java.base") && !req.modifiers().isEmpty())
             .collect(Collectors.toSet());
    reqs.stream()
        .sorted(Comparator.comparing(Requires::name))
        .forEach(req -> writer.format("    requires %s;%n",
                                      toString(req.modifiers(), req.name())));
    if (!reqs.isEmpty()) {
        writer.println();
    }

    if (!open) {
        md.exports().stream()
          .peek(exp -> {
              if (exp.isQualified())
                  throw new InternalError(md.name() + " qualified exports: " + exp);
              })
          .sorted(Comparator.comparing(Exports::source))
          .forEach(exp -> writer.format("    exports %s;%n", exp.source()));

        if (!md.exports().isEmpty()) {
            writer.println();
        }
    }

    md.provides().stream()
      .sorted(Comparator.comparing(Provides::service))
      .map(p -> p.providers().stream()
                 .map(impl -> "        " + impl.replace('$', '.'))
                 .collect(joining(",\n",
                                  String.format("    provides %s with%n",
                                                p.service().replace('$', '.')),
                                  ";")))
                 .forEach(writer::println);

    if (!md.provides().isEmpty()) {
        writer.println();
    }
    writer.println("}");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:59,代碼來源:ModuleInfoBuilder.java

示例13: printCompatHelp

import java.io.PrintWriter; //導入方法依賴的package包/類
static void printCompatHelp(PrintWriter out) {
    out.format("%s%n", Main.getMsg("usage.compat"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:GNUStyleOptions.java

示例14: printUsageTryHelp

import java.io.PrintWriter; //導入方法依賴的package包/類
static void printUsageTryHelp(PrintWriter out) {
    out.format("%s%n", Main.getMsg("main.usage.summary.try"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:GNUStyleOptions.java

示例15: printVersion

import java.io.PrintWriter; //導入方法依賴的package包/類
static void printVersion(PrintWriter out) {
    out.format("%s %s%n", "jar", System.getProperty("java.version"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:GNUStyleOptions.java


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