Java 8 PipedReader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PipedReader class.

This code example shows how to use the following methods: connect, read, sleep
     * @tests java.io.PipedReader#connect(java.io.PipedWriter) 
     */ 
    public void test_connectLjava_io_PipedWriter() throws Exception { 
        char[] c = null;
 
        preader = new PipedReader();
        t = new Thread(pwriter = new PWriter(), "");
        preader.connect(pwriter.pw);
        t.start();
        Thread.sleep(500); // Allow writer to start
        c = new char[11];
        preader.read(c, 0, 11);
 
        assertEquals("Read incorrect chars", "Hello World", new String(c));
        try { 
            preader.connect(pwriter.pw);
            fail("Failed to throw exception connecting to pre-connected reader");
        } catch (IOException e) {
            // Expected 
        } 
    } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: connect, read, sleep
     * @tests java.io.PipedReader#connect(java.io.PipedWriter) 
     */ 
    public void test_connectLjava_io_PipedWriter() throws Exception { 
        char[] c = null;
 
        preader = new PipedReader();
        t = new Thread(pwriter = new PWriter(), "");
        preader.connect(pwriter.pw);
        t.start();
        Thread.sleep(500); // Allow writer to start
        c = new char[11];
        preader.read(c, 0, 11);
 
        assertEquals("Read incorrect chars", "Hello World", new String(c));
        try { 
            preader.connect(pwriter.pw);
            fail("Failed to throw exception connecting to pre-connected reader");
        } catch (IOException e) {
            // Expected 
        } 
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, read, sleep
    /** 
     * @tests java.io.PipedReader#close() 
     */ 
    public void test_close() throws Exception { 
        char[] c = null;
        preader = new PipedReader();
        t = new Thread(new PWriter(preader), "");
        t.start();
        Thread.sleep(500); // Allow writer to start
        c = new char[11];
        preader.read(c, 0, 11);
        preader.close();
        assertEquals("Read incorrect chars", "Hello World", new String(c));
    } 
 
    /** 
     * @tests java.io.PipedReader#connect(java.io.PipedWriter) 
     */ 
    public void test_connectLjava_io_PipedWriter() throws Exception { 
        char[] c = null;
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: read
        testInterruptOutputStream(out);
    } 
 
    public void testInterruptPipedReader() throws Exception {
        PipedWriter writer = new PipedWriter();
        PipedReader reader = new PipedReader(writer);
        testInterruptReader(reader);
    } 
 
    public void testInterruptPipedWriter() throws Exception {
        final PipedWriter writer = new PipedWriter();
        new PipedReader(writer);
        testInterruptWriter(writer);
    } 
 
    public void testInterruptReadablePipeChannel() throws Exception {
        testInterruptReadableChannel(Pipe.open().source());
    } 
 
    public void testInterruptWritablePipeChannel() throws Exception {

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
    	 
        pr = new PipedReader();
        pw = new PipedWriter(pr);
        pr.close();
	 
        try { 
            pw.flush();
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
    } 
 
    /** 
     * @tests java.io.PipedWriter#write(char[], int, int) 
     */ 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 PipedReader Methods: