Code example for PrintStream

Methods: flush, format

0
 
    /** 
     * @tests java.io.PrintStream#format(java.lang.String, java.lang.Object...) 
     */ 
    public void test_formatLjava_lang_String$Ljava_lang_Object() { 
        PrintStream os = new PrintStream(bos, false);
        os.format("%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#format(java.util.Locale, java.lang.String, 
     *        java.lang.Object...) 
     */ 
    public void test_formatLjava_util_Locale_Ljava_lang_String_$Ljava_lang_Object() {