public PortScan setPorts(String portString) {

        ports.clear();

        ArrayList<Integer> ports = new ArrayList<>();

        if (portString == null) {
            throw new IllegalArgumentException("Empty port string not allowed");
        }

        portString = portString.substring(portString.indexOf(":") + 1, portString.length());

        for (String x : portString.split(",")) {
            if (x.contains("-")) {
                int start = Integer.parseInt(x.split("-")[0]);
                int end = Integer.parseInt(x.split("-")[1]);
                validatePort(start);
                validatePort(end);
                if (end <= start)
                    throw new IllegalArgumentException("Start port cannot be greater than or equal to the end port");

                for (int j = start; j <= end; j++) {
                    ports.add(j);
                }
            } else {
                int start = Integer.parseInt(x);
                validatePort(start);
                ports.add(start);
            }
        }

        this.ports = ports;

        return this;
    }
Scan the ports to scan

@param portString - the ports to scan (comma separated, hyphen denotes a range). For example:
                  "21-23,25,45,53,80"
@return this object to allow chaining
library/src/main/java/com/stealthcopter/networktools/PortScan.java