code: public void write(final DataOutputStream out) throws IOException
      {
          // Packet Type
          out.writeByte(packetType.ordinal());
  
          // Packet ID
          out.writeShort(packetID);
  
          // Data Length
          out.writeInt(dataLength);
  
          // Data
          out.write(data);
      }
docs: Writes Packet into DataOutputStream
  @param out DataOutputStream to write into
  @throws IOException when unable to write to stream