Code example for PrintStream

Methods: append, close, flush

0
     * @tests java.io.PrintStream#append(CharSequence, int, int) 
     */ 
    public void test_appendCharSequenceIntInt() { 
        String testString = "My Test String";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out);
        printStream.append(testString, 1, 3);
        printStream.flush();
        assertEquals(testString.substring(1, 3), out.toString());
        printStream.close();
    } 
 
    /** 
     * @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];