- private static LinkedList<String> getMxHosts(String domain) throws IOException {
- LinkedList<String> mxhosts = new LinkedList<String>();
- Process dig = Runtime.getRuntime().exec(new String[] {
- "dig", "+short", "MX", domain
- });
- try (BufferedReader br = new BufferedReader(new InputStreamReader(dig.getInputStream()))) {
- String line;
- while ((line = br.readLine()) != null) {
- String[] mxparts = line.split(" ", 2);
- if (mxparts.length != 2) {
- continue;
- }
- mxhosts.add(mxparts[1].substring(0, mxparts[1].length() - 1));
+ private static void sortMX(String[] mxhosts) {
+ Arrays.sort(mxhosts, new Comparator<String>() {
+
+ @Override
+ public int compare(String o1, String o2) {
+ int i1 = Integer.parseInt(o1.split(" ")[0]);
+ int i2 = Integer.parseInt(o2.split(" ")[0]);
+ return Integer.compare(i1, i2);