Code example for PrintStream

Methods: appendcloseflush

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);
Contextual code suggestions in your IDE  Get Codota for Java