Code example for PipedOutputStream

Methods: close, write

0
 
    public void test_ConstructorLjava_io_PipedInputStream() throws IOException { 
        // Test for method java.io.PipedOutputStream(java.io.PipedInputStream) 
 
        try { 
            out = new PipedOutputStream(new PipedInputStream());
            out.write('b');
        } catch (Exception e) {
            fail("Test 1: Constructor failed: " + e.getMessage());
        } 
        out.close();
 
        PipedInputStream pis = new PipedInputStream(new PipedOutputStream());
        try { 
            out = new PipedOutputStream(pis);
            fail("Test 2: IOException expected because the input stream is already connected.");
        } catch (IOException e) {
            // Expected. 
        } 
    }