Netbeans Platform: InstalledFileLocator

I added a resource for the module as follows:

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>nbm-maven-plugin</artifactId> <extensions>true</extensions> <configuration> <moduleType>eager</moduleType> <nbmResources> <nbmResource> <directory>${basedir}/resources</directory> <targetPath>resources</targetPath> <includes> <include>*.db</include> </includes> <excludes> <exclude>*trace*</exclude> </excludes> </nbmResource> </nbmResources> </configuration> </plugin> 

The file is displayed in the Netbeans application at: target/app name/app name/resources/card_manager.mv.db . It looks good.

Now I am trying to get this file location as follows:

 File db = InstalledFileLocator.getDefault().locate("card_manager.mv.db", "module.codename.base", false); 

But db is always zero. Any idea?

+5
source share
2 answers

Try this code ...

 File file = InstalledFileLocator.getDefault().locate("myfile", null, false); if (file == null) { file = new File(Places.getUserDirectory() + File. separator + "myfile"); } 

Or have you tried the resources / card _manager.mv.db? I am sure that the application path (application name) and cluster name (middle name of the application) are excluded from locate (), but I believe you need to include the resources / path.

0
source

Change your pom so that card_manager.mv.db copied to the classes folder, not the resources folder, and extract the file from your class loader.

0
source

All Articles