Code example for DatagramChannel

Methods: send

	private boolean doSend(final String stat) {
		try { 
			final byte[] data = stat.getBytes("utf-8");
			final ByteBuffer buff = ByteBuffer.wrap(data);
			final int nbSentBytes = _channel.send(buff, _address);
			if (data.length == nbSentBytes) {
				return true; 
			} else { 
						"Could not send entirely stat %s to host %s:%d. Only sent %i bytes out of %i bytes", stat,
						_address.getHostName(), _address.getPort(), nbSentBytes, data.length));
				return false; 
		} catch (IOException e) {
					String.format("Could not send stat %s to host %s:%d", stat, _address.getHostName(),
							_address.getPort()), e);
Connect your IDE to all the code out there  Get Codota for Java