Code example for PrintStream

Methods: append, close, flush

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