Code example for PipedOutputStream

Methods: flushwrite

0
 
    /** 
     * @tests java.io.PipedOutputStream#flush() 
     */ 
    public void test_flush() throws IOException, UnsupportedEncodingException { 
        out = new PipedOutputStream();
        rt = new Thread(reader = new PReader(out));
        rt.start();
        out.write("HelloWorld".getBytes("UTF-8"), 0, 10);
        assertTrue("Bytes written before flush", reader.available() != 0);
        out.flush();
        assertEquals("Wrote incorrect bytes", "HelloWorld", reader.read(10));
    } 
 
    /** 
     * @tests java.io.PipedOutputStream#write(byte[], int, int) 
     */ 
    public void test_write$BII() throws IOException, UnsupportedEncodingException { 
        out = new PipedOutputStream();
        rt = new Thread(reader = new PReader(out));
Stop searching for code, let great code find you!  Add Codota to your java IDE