import java.util.*;
import org.xbill.DNS.*;

public class lookup {

public static void
printAnswer(String name, Record [] answer) {
	System.out.println(name + ":");
	if (answer == null)
		System.out.println("null");
	else
		for (int i = 0; i < answer.length; i++)
			System.out.println(answer[i]);
}

public static void
main(String [] args) throws Exception {
	short type = Type.A;
	int start = 0;
	if (args.length > 2 && args[0].equals("-t")) {
		type = Type.value(args[1]);
		if (type < 0)
			throw new IllegalArgumentException("invalid type");
		start = 2;
	}
	for (int i = start; i < args.length; i++)
		printAnswer(args[i], dns.getRecords(args[i], type));
}

}

@@ -109,24 +109,21 @@
 me, 
-Record %5B%5D answer
+Lookup lookup
 ) %7B%0A
@@ -139,18 +139,16 @@
 ut.print
-ln
 (name + 
@@ -162,59 +162,117 @@
 if (
-answer == null)%0A%09%09System.out.println(%22null%22);%0A%09else
+lookup.getResult() == Lookup.SUCCESSFUL) %7B%0A%09%09System.out.println();%0A%09%09Record %5B%5D answers = lookup.getAnswers();
 %0A%09%09f
@@ -296,16 +296,17 @@
 %3C answer
+s
 .length;
@@ -343,14 +343,82 @@
 swer
+s
 %5Bi%5D);%0A
+%09%7D else %7B%0A%09%09 System.out.println(%22 %22 + lookup.getErrorString());%0A%09%7D%0A
 %7D%0A%0Ap
@@ -724,46 +724,75 @@
 i++)
+ %7B
 %0A%09%09
-printAnswer(args%5Bi%5D, dns.getRecords
+Lookup l = new Lookup(args%5Bi%5D, type);%0A%09%09l.run();%0A%09%09printAnswer
 (arg
@@ -801,15 +801,14 @@
 i%5D, 
-type));
+l);%0A%09%7D
 %0A%7D%0A%0A

Use the Lookup class.