Code example for DatagramPacket

Methods: getLengthsetDatasetLength

     * @return  Length of actual data received. 
     * @exception IOException If an error occurs while receiving the data. 
    public int receive(byte[] data, int length) throws IOException
        return __receivePacket.getLength();
    /*** Same as <code> receive(data, data.length)</code> ***/ 
    public int receive(byte[] data) throws IOException
        return receive(data, data.length);
Connect your IDE to all the code out there  Get Codota for Java