Code example for DatagramChannel

Methods: connectreadsocketconfigureBlocking

0
     * @tests DatagramChannel#read(ByteBuffer[]) 
     */ 
    public void test_read_$LByteBuffer() throws Exception { 
        // regression test for Harmony-754 
        channel2.socket().bind(localAddr1);
        channel1.socket().bind(localAddr2);
        channel1.connect(localAddr1);
        channel2.connect(localAddr2);
        channel2.write(ByteBuffer.allocate(CAPACITY_NORMAL));
 
        ByteBuffer[] readBuf = new ByteBuffer[2];
        readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
        readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
 
        channel1.configureBlocking(true);
        assertEquals(CAPACITY_NORMAL, channel1.read(readBuf));
    } 
 
    /** 
     * @tests DatagramChannel#read(ByteBuffer[],int,int) 
     */ 
Connect your IDE to all the code out there  Get Codota for Java