[RSS]

How can I find out what is in a Lookup?

Do not do any of these things in production code!

The simplest way is to call Lookup.toString(). If you want the output in a more readable form, do the following and print/format the resulting collection as you wish:

NetBeans 5.x Code NetBeans 6 and up
Lookup.Template tpl = new Lookup.Template ( Object.class); Lookup.Result result = theLookup.lookup (tpl); Collection c = result.allInstances(); for (Iterator i=c.iterator(); i.hasNext();) { Object o = i.next(); //do what you want } Collection<? extends Object> c = theLookup.lookupAll(Object.class); for (Object o : c) { //do what you want }