I trying to work with a XML file from where a get a list of IPs and subnets, after that I want to check if those IP are within of a subnet.
QueryXML getNodes = new QueryXML(Queries);
NodeList IPs = getNodes.query();
QueryXML getSubnets = new QueryXML(Queries1);
NodeList subnets = getSubnets.query();
At this point, I already have my NodeList with each element from the XML file (Ips & subnets), but my problem now is that, I would like to convert those NodeList to Array and so, use the following element which is calling a constructur with two arrays as a parameter.
SubnetUtilsExample findobjects = new SubnetUtilsExample(IPs, subnets);
I googled it but i didnt find a right way. Could somebody help me with that?
Thanks.
Since Java 8, you can work with IntStream and map, where nodeList is instance of NodeList
:
List<Node> nodes = IntStream.range(0, nodeList.getLength())
.mapToObj(nodeList::item)
.collect(Collectors.toList());