- 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));
- }
- }
- return mxhosts;
- }