Code example for DatagramPacket

Methods: getData, getLength

0
	public static Logger			logger				= Logger.getLogger("DNS");
	public static ExecutorService	executor			= Executors
																.newCachedThreadPool();
 
	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];
	}