PrintWriter printf - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PrintWriter printf method.

This code example shows how to use the following methods:close, printf
		return tid;
	} 
 
	public static String snprintf(int size, String format, Object... args) {
		StringWriter writer = new StringWriter(size);
		PrintWriter out = new PrintWriter(writer);
		out.printf(format, args);
		out.close();
		return writer.toString();
	} 
 
	public RowKey() { 
		this.uid = 0;
		this.itype = (byte) '0';
		this.tid = 0;
		String rk = snprintf(17, "%s", "");
		buffer = ByteBuffer.wrap(rk.getBytes());
	} 
 
	public RowKey(String rowkey) {
8
CodeRank
This code example shows how to use the following methods:close, print, printf, println
        } 
    } 
 
    private static String getFailureText(final Object orig, final Object copy) {
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw);
 
        pw.println("Test FAILED: Deserialized object is not equal to the original object");
        pw.print("\tOriginal: ");
        printObject(pw, orig).println();
        pw.print("\tCopy:     ");
        printObject(pw, copy).println();
 
        pw.close();
        return sw.toString();
    } 
 
    private static PrintWriter printObject(final PrintWriter pw, final Object o) {
        pw.printf("%s@%08x", o.getClass().getName(), System.identityHashCode(o));
        return pw;

7
CodeRank
This code example shows how to use the following methods:checkError, printf
productList.add(identifier);
 
            final String productType = product.getProductType();
 
            productMapWriter.printf("%d\t%s\t%s%n", productList.indexOf(identifier), productType,
                                    identifier.getLocation());
 
            if (productMapWriter.checkError()) {
                throw new IOException("Error occurred while writing measurement.");
            } 
 
        } 
        return productList.indexOf(identifier);
    } 
 
    @Override 
    public void close() { 
        if (productMapWriter != null) {
            productMapWriter.close();
7
CodeRank
This code example shows how to use the following methods:printf
        this.exportExpressionResult = exportExpressionResult;
        includeExpressionInTable = expression != null && exportExpressionResult;
    } 
 
    protected void writeStandardHeader(PrintWriter writer) {
        writer.printf("# BEAM pixel extraction export table%n");
        writer.printf("#%n");
        writer.printf(Locale.ENGLISH, "# Window size: %d%n", windowSize);
        if (expression != null) {
            writer.printf("# Expression: %s%n", expression);
        } 
 
        final DateFormat dateFormat = ProductData.UTC.createDateFormat("yyyy-MM-dd HH:mm:ss");
        writer.printf(Locale.ENGLISH, "# Created on:\t%s%n%n", dateFormat.format(new Date()));
    } 
 
    protected void writeWavelengthLine(PrintWriter writer, Product product) {
        final String[] rasterNames = rasterNamesFactory.getRasterNames(product);
        if (product != null) {
            ArrayList<Float> wavelengthList = new ArrayList<Float>();
7
CodeRank
This code example shows how to use the following methods:printf
        if (context == null)
        { 
            out.println("context = null");
            return; 
        } 
        out.printf("context = %s%n",context);
        out.printf("context.contextPath = %s%n",context.getContextPath());
        out.printf("context.effective-version = %d.%d%n",context.getEffectiveMajorVersion(),context.getEffectiveMinorVersion());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:printf, println
     * 
     * @return footprint table 
     */ 
    public String toFootprint() {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.println(name + " instance footprint:");
        pw.printf(" %9s %9s %9s   %s%n", "COUNT", "AVG", "SUM", "DESCRIPTION");
        for (Class<?> key : getClasses()) {
            int count = getClassCounts().count(key);
            int size = getClassSizes().count(key);
            pw.printf(" %9d %9d %9d   %s%n", count, size / count, size, key.getName());
        } 
        pw.printf(" %9d %9s %9d   %s%n", totalCount(), "", totalSize(), "(total)");
        pw.println();
        pw.close();
        return sw.toString();
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:x 1
            ChannelEndPoint channelEndPoint = (ChannelEndPoint)endPoint;
            Socket socket = channelEndPoint.getSocket();
            ServerConnector connector = (ServerConnector)baseRequest.getHttpChannel().getConnector();
 
            PrintWriter out = response.getWriter();
            out.printf("connector.getReuseAddress() = %b%n",connector.getReuseAddress());
 
            try 
            { 
                Field fld = connector.getClass().getDeclaredField("_reuseAddress");
                assertThat("Field[_reuseAddress]",fld,notNullValue());
                fld.setAccessible(true);
                Object val = fld.get(connector);
                out.printf("connector._reuseAddress() = %b%n",val);
            } 
            catch (Throwable t)
            { 
                t.printStackTrace(out);
            } 
             

6
CodeRank
This code example shows how to use the following methods:close, printf, println
        } 
    } 
 
    public static String vmDetails() {
        StringWriter sw = new StringWriter();
        PrintWriter out = new PrintWriter(sw);
 
        out.println("Running " + (ADDRESS_SIZE * 8) + "-bit " + VM_NAME + " VM.");
        if (USE_COMPRESSED_REFS)
            out.println("Using compressed references with " + COMPRESSED_REF_SHIFT + "-bit shift.");
        out.println("Objects are " + OBJ_ALIGNMENT + " bytes aligned.");
 
        out.printf("%-19s: %d, %d, %d, %d, %d, %d, %d, %d, %d [bytes]%n",
                "Field sizes by type", 
                REF_SIZE,
                BOOLEAN_SIZE,
                BYTE_SIZE,
                CHAR_SIZE,
                SHORT_SIZE,
                INT_SIZE,

6
CodeRank
This code example shows how to use the following methods:flush, printf
 
    /** 
     * @tests java.io.PrintWriter#printf(java.lang.String, java.lang.Object...) 
     */ 
    public void test_printfLjava_lang_String$Ljava_lang_Object() { 
        pw.printf("%s %s", "Hello", "World");
        pw.flush();
        assertEquals("Wrote incorrect string", "Hello World",
                new String(bao.toByteArray()));
    } 
 
    /** 
     * @tests java.io.PrintWriter#printf(java.util.Locale, java.lang.String, java.lang.Object...) 
     */ 
    public void test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() { 
        pw.printf(Locale.US, "%s %s", "Hello", "World");
        pw.flush();
        assertEquals("Wrote incorrect string", "Hello World",
                new String(bao.toByteArray()));
    } 
4
CodeRank
This code example shows how to use the following methods:printf
    } 
 
    @Override 
    public PrintWriter printf(Locale l, String format, Object... args) {
        committer.commitHeaders();
        return originalWriter.printf(l, format, args);
    } 
 
    @Override 
    public PrintWriter format(String format, Object... args) {
        committer.commitHeaders();
        return originalWriter.format(format, args);
    } 
 
    @Override 
    public PrintWriter format(Locale l, String format, Object... args) {
        committer.commitHeaders();
        return originalWriter.format(l, format, args);
    } 
 
5
CodeRank

Related PrintWriter printf Questions & Answers:

printf Method Overview
A convenience method to write a formatted string to this writer using the specified format string and arguments.
See Code Examples for other Java 8 PrintWriter Methods: