Code example for DatagramChannel

Methods: write

0
		return receive(); 
	} 
 
	private void send(final @NotNull byte[] data) throws IOException
	{ 
		channel.write(wrap(data));
	} 
 
	@NotNull 
	private byte[] receive() throws IOException 
	{ 
		selectorKeyHelper.blockUntilReady(OP_READ);
		final int maximumMessageSize = 512;
		byte[] buffer = new byte[maximumMessageSize];
		long numberOfBytesRead = channel.read(wrap(buffer));
		if (numberOfBytesRead <= 0)
		{ 
			return EmptyByteArray; 
		} 
		return copyOf(buffer, (int) numberOfBytesRead);
Connect your IDE to all the code out there  Get Codota for Java