I have this function which returns a datatype InetAddress[]
public InetAddress []
lookupAllHostAddr(String host) throws UnknownHostException {
Name name = null;
try {
name = new Name(host);
}
catch (TextParseException e) {
throw new UnknownHostException(host);
}
Record [] records = null;
if (preferV6)
records = new Lookup(name, Type.AAAA).run();
if (records == null)
records = new Lookup(name, Type.A).run();
if (records == null && !preferV6)
records = new Lookup(name, Type.AAAA).run();
if (records == null)
throw new UnknownHostException(host);
InetAddress[] array = new InetAddress[records.length];
for (int i = 0; i < records.length; i++) {
Record record = records[i];
if (records[i] instanceof ARecord) {
ARecord a = (ARecord) records[i];
array[i] = a.getAddress();
} else {
AAAARecord aaaa = (AAAARecord) records[i];
array[i] = aaaa.getAddress();
}
}
return array;
}
Eclipse complains that the return type should be byte[][] but when I change the return type to byte[][], it complains that the function is returning the wrong data type. I'm stuck in a loop. Does anyone know what is happening here?