Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 24

Download

I have a folder full of .instance files. How do I get any/all of the object instances?

Often registries of objects are created by placing files with the extension .instance into some folder in the system filesystem. The task, then, is to turn a folder full of files into a collection of objects, and make sure we only get objects of the type we are interested in. In NetBeans 6 it is very simple to do that:

Lookup myObjects = Lookups.forPath ("path/to/folder/in/sysfs");
Collection <? extends MyType> c = myObjects.lookupAll(MyType.class);

(note the separator is always / with NetBeans filesystems).

If you have a single .instance file and need to get an object for that, see this FAQ entry.