Code example for PrintStream

Methods: append, close, flush

0
     * @tests java.io.PrintStream#append(char) 
     */ 
    public void test_appendChar() throws IOException { 
        char testChar = ' ';
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out);
        printStream.append(testChar);
        printStream.flush();
        assertEquals(String.valueOf(testChar), out.toString());
        printStream.close();
    } 
 
    /** 
     * @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();