Code example for DatagramPacket

Methods: getDatagetLength

	public static Logger			logger				= Logger.getLogger("DNS");
	public static ExecutorService	executor			= Executors
	public static byte[] dataFromPacket(DatagramPacket packet){
		return Arrays.copyOf(packet.getData(), packet.getLength());
	public static DatagramPacket packetFromData(byte[] data){
		return new DatagramPacket(data, data.length);
	private static final int	BUFFER_LENGTH	= 65536;
	public static DatagramPacket newPacket(){
		return new DatagramPacket(new byte[BUFFER_LENGTH], BUFFER_LENGTH);
	public static byte[] newBuffer(){ 
		return new byte[BUFFER_LENGTH];
Connect your IDE to all the code out there  Get Codota for Java