本文整理汇总了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);
}
}
示例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"));
}
示例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();
}
示例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);
}
}
示例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));
}
示例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");
}
示例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();
}
}
示例8: field
import java.io.PrintWriter; //导入方法依赖的package包/类
private static void field(PrintWriter out, String name, Object value) {
out.format("%s: %s%n", name, value);
}
示例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);
}
示例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());
}
示例11: SummaryDotFile
import java.io.PrintWriter; //导入方法依赖的package包/类
SummaryDotFile(PrintWriter writer, Analyzer.Type type) {
this.writer = writer;
this.type = type;
writer.format("digraph \"summary\" {%n");
}
示例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("}");
}
示例13: printCompatHelp
import java.io.PrintWriter; //导入方法依赖的package包/类
static void printCompatHelp(PrintWriter out) {
out.format("%s%n", Main.getMsg("usage.compat"));
}
示例14: printUsageTryHelp
import java.io.PrintWriter; //导入方法依赖的package包/类
static void printUsageTryHelp(PrintWriter out) {
out.format("%s%n", Main.getMsg("main.usage.summary.try"));
}
示例15: printVersion
import java.io.PrintWriter; //导入方法依赖的package包/类
static void printVersion(PrintWriter out) {
out.format("%s %s%n", "jar", System.getProperty("java.version"));
}