当前位置: 首页>>代码示例>>Java>>正文


Java PrintStream.format方法代码示例

本文整理汇总了Java中java.io.PrintStream.format方法的典型用法代码示例。如果您正苦于以下问题:Java PrintStream.format方法的具体用法?Java PrintStream.format怎么用?Java PrintStream.format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.PrintStream的用法示例。


在下文中一共展示了PrintStream.format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeBeginning

import java.io.PrintStream; //导入方法依赖的package包/类
@Override public void writeBeginning(final PrintStream out) {
    out.format("\tpublic %1$s(final long objPtr, final %2$s runtime) {\n" +
            "\t\tsuper(objPtr, runtime);\n" +
            "\t}\n",
        className, JObjCRuntime.class.getCanonicalName());

    out.format("\tpublic %1$s(final %1$s obj, final %2$s runtime) {\n" +
            "\t\tsuper(obj, runtime);\n" +
            "\t}\n",
        className, JObjCRuntime.class.getCanonicalName());

    NativeObjectLifecycleManager nolm = nolmForClass.get(clazz.name);
    if(nolm != null)
        out.format("\[email protected]\n"+
                "\tprotected %1$s getNativeObjectLifecycleManager() {\n" +
                "\t\treturn %2$s.INST;\n" +
                "\t}\n",
                NativeObjectLifecycleManager.class.getCanonicalName(), nolm.getClass().getCanonicalName());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:JObjCClassFile.java

示例2: writeBeginning

import java.io.PrintStream; //导入方法依赖的package包/类
@Override public void writeBeginning(final PrintStream out) {
    out.format(
            "\tpublic %1$s(%2$s runtime) {\n" +
            "\t\tsuper(runtime);\n" +
            "\t}\n",
            className, JObjCRuntime.class.getCanonicalName());
    out.format(
            "\tpublic %1$s(String name, %2$s runtime) {\n" +
            "\t\tsuper(name, runtime);\n" +
            "\t}\n",
            className, JObjCRuntime.class.getCanonicalName());
    out.format(
            "\tpublic %1$s(long ptr, %2$s runtime) {\n" +
            "\t\tsuper(ptr, runtime);\n" +
            "\t}\n",
            className, JObjCRuntime.class.getCanonicalName());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:JObjCClassClassFile.java

示例3: writeBeginning

import java.io.PrintStream; //导入方法依赖的package包/类
@Override public void writeBeginning(final PrintStream out) {
    out.println();
    out.println("\tpublic static int SIZEOF = " + JObjCRuntime.class.getName() + ".IS64 ? "
            + ((NStruct) struct.type.type64).sizeof64() + " : " + ((NStruct) struct.type.type32).sizeof32() + ";");
    out.println();
    out.format("\tpublic final static %1$s getStructCoder(){ return coder; }\n", StructCoder.class.getCanonicalName());
    out.format("\[email protected] public final %1$s getCoder(){ return coder; }\n", StructCoder.class.getCanonicalName());
    out.format("\tprivate final static %1$s coder = new %1$s(SIZEOF%2$s%3$s){\n", StructCoder.class.getCanonicalName(),
            (struct.fields.size() > 0 ? ",\n\t\t" : ""),
            Fp.join(",\n\t\t", Fp.map(new Map1<Field,String>(){
                public String apply(Field a) {
                    return a.type.getJType().getCoderDescriptor().getCoderInstanceName();
                }}, struct.fields)));
    out.format("\t\[email protected] protected %1$s newInstance(%2$s runtime){ return new %1$s(runtime); }\n",
            struct.name,
            JObjCRuntime.class.getCanonicalName());
    out.println("\t};");
    out.println();
    out.println("\t" + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime){");
    out.println("\t\tsuper(runtime, SIZEOF);");
    out.println("\t}");
    out.println();
    out.println("\tpublic " + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime, final com.apple.jobjc.NativeBuffer buffer) {");
    out.println("\t\tsuper(runtime, buffer, SIZEOF);");
    out.println("\t}");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:StructClassFile.java

示例4: writeField

import java.io.PrintStream; //导入方法依赖的package包/类
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:StructClassFile.java

示例5: generateSerializedInet6AddressData

import java.io.PrintStream; //导入方法依赖的package包/类
static byte[] generateSerializedInet6AddressData(Inet6Address addr,
        PrintStream out, boolean outputToFile) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
        oos.writeObject(addr);
    }

    String ifname = getIfName(addr);
    byte[] ba = bos.toByteArray();
    if (out != null) {
        out.format("static final byte[] SerialData" + ifname + " = {\n");
        for (int i = 0; i < ba.length; i++) {
            out.format(" (byte)0x%02X", ba[i]);
            if (i != (ba.length - 1))
                out.format(",");
            if (((i + 1) % 6) == 0)
                out.format("\n");
        }
        out.format(" };\n \n");
    }
    if (outputToFile) {
        serializeInet6AddressToFile(addr);
    }
    return ba;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:Inet6AddressSerializationTest.java

示例6: printToStream

import java.io.PrintStream; //导入方法依赖的package包/类
public static void printToStream(double[][] A, PrintStream strm) {
	String fStr = PrintPrecision.getFormatStringFloat();
	strm.format("{");
	for (int i=0; i< A.length; i++) {
		if (i == 0)
			strm.format("{");
		else
			strm.format(", \n{");
		for (int j=0; j< A[i].length; j++) {
			if (j == 0) 
				strm.format(loc, fStr, A[i][j]);
			else
				strm.format(loc, ", " + fStr, A[i][j]);
		}
		strm.format("}");
	}
	strm.format("}");
	strm.flush();
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:20,代码来源:Matrix.java

示例7: printThreadsDump

import java.io.PrintStream; //导入方法依赖的package包/类
private void printThreadsDump(PrintStream stream, Map<Thread, StackTraceElement[]> threads)
{
    stream.format(
        "#Threads: %d, #Blocked: %d%n%n",
        threads.size(),
        blockedThreads.size()
    );
    threads.forEach((thread, stack) -> {
        stream.format(
            "Thread:%d '%s' %sprio=%d %s%n",
            thread.getId(),
            thread.getName(),
            thread.isDaemon() ? "deamon " : "",
            thread.getPriority(),
            thread.getState()
        );
        for (StackTraceElement line: stack)
            stream.println("        " + line);
        stream.println();
    });
}
 
开发者ID:toptal,项目名称:jvm-monitoring-agent,代码行数:22,代码来源:Agent.java

示例8: printLine

import java.io.PrintStream; //导入方法依赖的package包/类
private void printLine(PrintStream out, SectionsMerger merger, EvaluationContext ctx, Element elt, String forceType) {
	String id = merger.getId(elt);
	String type = forceType == null ? this.type.evaluateString(ctx, elt) : forceType;
	out.format("%s\t%s", id, type);
	printInfo(out, merger, ctx, elt);
	out.println();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:8,代码来源:AlvisREAnnotations.java

示例9: printInfo

import java.io.PrintStream; //导入方法依赖的package包/类
@Override
protected void printInfo(PrintStream out, SectionsMerger merger, EvaluationContext ctx, Element elt) {
	int start = this.start.evaluateInt(ctx, elt);
	int end = this.end.evaluateInt(ctx, elt);
	String form = this.form.evaluateString(ctx, elt);
	out.format(" %d %d\t%s", merger.correctOffset(start), merger.correctOffset(end), form.replace('\n', ' '));
	for (Evaluator l : layers) {
		String ls = l.evaluateString(ctx, elt);
		out.print('|');
		out.print(ls);
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:13,代码来源:AlvisRETokens.java

示例10: writeBeginning

import java.io.PrintStream; //导入方法依赖的package包/类
@Override public void writeBeginning(final PrintStream out) {
    String targetCls = category.category.superClass.getFullPath();
    out.format("\tpublic %1$s(final %2$s obj, final %3$s runtime) {\n" +
            "\t\tsuper(obj, runtime);\n" +
            "\t}\n",
        className, targetCls, JObjCRuntime.class.getCanonicalName());
    super.writeBeginning(out);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:CategoryClassFile.java

示例11: writeBeginning

import java.io.PrintStream; //导入方法依赖的package包/类
@Override public void writeBeginning(final PrintStream out) {
    out.format(
            "\t%1$s(%2$s runtime) {\n" +
            "\t\tsuper(\"%3$s\", runtime);\n" +
            "\t}\n",
            className, JObjCRuntime.class.getCanonicalName(), category.category.superClass.name);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:CategoryClassClassFile.java

示例12: dumpBuffer

import java.io.PrintStream; //导入方法依赖的package包/类
public static void dumpBuffer (final PrintStream out, final String label, final byte[] b, final int offset, final int len) {
	if(label != null)
		out.format ( "-- %s -- :\n", label );
	out.format("{\n    ", label);
	for( int j = 0; j < len ; ++j ) {
		out.format ("%02X", b[j + offset]);
		if(j+1 < len) {
			if ((j+1)%8==0) out.print("\n    ");
			else out.print(' ');
		}
	}
	out.format("\n}\n");
}
 
开发者ID:andreas1327250,项目名称:argon2-java,代码行数:14,代码来源:Blake2b.java

示例13: processSentence

import java.io.PrintStream; //导入方法依赖的package包/类
private void processSentence(PrintStream out, Logger logger, Collection<Tuple> dependencies, Section sec, Annotation sent) {
	out.println(">>");
	out.println(">Word");
	IndexHashMap<Annotation> wordIndex = new IndexHashMap<Annotation>();
	Layer wordLayer = sec.getLayer(words);
	StringBuilder sb = new StringBuilder();
	for (Annotation w : wordLayer.between(sent)) {
		sb.setLength(0);
		Strings.escapeWhitespaces(sb, w.getLastFeature(wordForm));
		out.format("%d\t\"%s\"\n", wordIndex.safeGet(w), sb);
	}
	if (entities != null) {
		for (String name : entities) {
			Layer entityLayer = sec.ensureLayer(name);
			out.println(">Entities");
			for (Annotation e : entityLayer.between(sent)) {
				Layer includedWords = wordLayer.overlapping(e);
				if (includedWords.isEmpty()) {
					logger.warning("entity " + e + " dos not include any word");
					continue;
				}
				if (includedWords.size() == 1) {
					out.format("%d\t\"%s\"\n", wordIndex.safeGet(includedWords.first()), e.getLastFeature(entityType));
				}
				else {
					out.format("%d\t%d\t\"%s\"\n", wordIndex.safeGet(includedWords.first()), wordIndex.safeGet(includedWords.last()), e.getLastFeature(entityType));
				}
			}
		}
	}
	out.println(">Relations");
	for (Tuple t : dependencies) {
		if (!t.hasArgument(head)) {
			logger.warning("dependency without head");
			continue;
		}
		if (!t.hasArgument(dependent)) {
			logger.warning("dependency without dependent");
			continue;
		}
		Annotation headWord = DownCastElement.toAnnotation(t.getArgument(head));
		Annotation dependentWord = DownCastElement.toAnnotation(t.getArgument(dependent));
		if (!wordLayer.contains(headWord)) {
			logger.warning("head not in the word layer");
			continue;
		}
		if (!wordLayer.contains(dependentWord)) {
			logger.warning("dependent not in the word layer");
			continue;
		}
		if (!wordIndex.containsKey(headWord)) {
			logger.warning("head outisde sentence");
			continue;
		}
		if (!wordIndex.containsKey(dependentWord)) {
			logger.warning("dependent outisde sentence");
			continue;
		}
		int h = wordIndex.get(headWord);
		int d = wordIndex.get(dependentWord);
		out.format("%d\t%d\t\"%s\"\n", h, d, t.getLastFeature(label));
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:64,代码来源:WhatsWrongExport.java

示例14: writeLocalWrapperScript

import java.io.PrintStream; //导入方法依赖的package包/类
@Override
protected void writeLocalWrapperScript(Path launchDst, Path pidFile, PrintStream pout) {
  pout.format("@call \"%s\"", launchDst);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:WindowsSecureContainerExecutor.java

示例15: writeTo

import java.io.PrintStream; //导入方法依赖的package包/类
void writeTo(PrintStream out, Set<ModuleDescriptor> selectedModules) {
    out.format("<html><head>%n");
    out.format("<title>%s</title>%n", title);
    // stylesheet
    Arrays.stream(HtmlDocument.STYLES).forEach(out::println);
    out.format("</head>%n");

    // body begins
    out.format("<body>%n");

    // title and date
    out.println(DOCTITLE.toString(title));
    out.println(VERSION.toString(String.format("%tc", new Date())));

    // total modules and sizes
    long totalBytes = selectedModules.stream()
            .map(ModuleDescriptor::name)
            .map(modules::get)
            .mapToLong(ModuleSummary::uncompressedSize)
            .sum();
    String[] sections = new String[] {
            String.format("%s: %d", "Total modules", selectedModules.size()),
            String.format("%s: %,d bytes (%s %s)", "Total size",
                          totalBytes,
                          System.getProperty("os.name"),
                          System.getProperty("os.arch"))
    };
    out.println(SECTION.toString(sections));

    // write table and header
    out.println(String.format("<table class=\"%s\">", MODULES));
    out.println(header("Module", "Requires", "Exports",
            "Services", "Commands/Native Libraries/Configs"));

    // write contents - one row per module
    selectedModules.stream()
            .sorted(Comparator.comparing(ModuleDescriptor::name))
            .map(m -> modules.get(m.name()))
            .map(ModuleTableRow::new)
            .forEach(table -> table.writeTo(out));

    out.format("</table>");  // end table
    out.format("</body>");
    out.println("</html>");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:ModuleSummary.java


注:本文中的java.io.PrintStream.format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。