Code example for PrintStream

Methods: flush, printf

0
 
    /** 
     * @tests java.io.PrintStream#printf(java.lang.String, java.lang.Object...) 
     */ 
    public void test_printfLjava_lang_String$Ljava_lang_Object() { 
        PrintStream os = new PrintStream(bos, false);
        os.printf("%s %s", "Hello", "World");
        os.flush();
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        byte[] rbytes = new byte[11];
        bis.read(rbytes, 0, rbytes.length);
        assertEquals("Wrote incorrect string", "Hello World",
                new String(rbytes));
    } 
 
    /** 
     * @tests java.io.PrintStream#printf(java.util.Locale, java.lang.String, 
     *        java.lang.Object...) 
     */ 
    public void test_printfLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() { 
        PrintStream os = new PrintStream(bos, false);