DevFaqLookupContents

(Difference between revisions)
m (How can I find out what is in a Lookup?)
 
Line 4: Line 4:
The simplest way is to call <tt>Lookup.toString()</tt>.  If you want the output in a more readable form, do the following and print/format the resulting collection as you wish:
The simplest way is to call <tt>Lookup.toString()</tt>.  If you want the output in a more readable form, do the following and print/format the resulting collection as you wish:
-
Collection<?> c = theLookup.lookupAll(Object.class);
+
<source lang="java">
-
for (Object o : c) {
+
Collection<?> c = theLookup.lookupAll(Object.class);
-
  //do what you want
+
for (Object o : c) {
-
}
+
  //do what you want
 +
}
 +
</source>
'''<u>Do not</u> do either of these things in production code!'''
'''<u>Do not</u> do either of these things in production code!'''

Current revision as of 20:16, 24 July 2010

How can I find out what is in a Lookup?

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:

Collection<?> c = theLookup.lookupAll(Object.class);
for (Object o : c) {
  //do what you want
}

Do not do either of these things in production code!

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo