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