I am writing test cases that have to be executed in 开发者_运维技巧osgi environment, i have put the test data which is a set of files in the test bundle. I am able to access the test data files using bundle.getResource which returns an URL from which i can get the InputStream for a particular file, but how can i find out all the list of files in a particular folder in the test plugin. In eclispe i could use fileLocator to do this.
/bundle
testdata one.txt two.txt three.txt folder1 file1.txt file2.txtIn the above bundle i want to find all the files and folders that are present in the testdata folder.
Best Reards, KeshavIf you know what bundle the information is in, use Bundle.findEntries or Bundle.getEntryPaths.
Resources (classes, files, streams etc) accessed by the classloader can be provided by everything. Usually, resources are loaded from a JAR file. But it could be a database, a file system or a HTTP resource, too. So in order to get a list of resources, you depend on the source behind the classloader. In case the resources are located inside a JAR, you'll need to get the JAR itself and access it through e.g. java.util.zip. Since, the ClassLoader interface does not provide information about the source behind, you have to go other ways (like hooking into the OSGi framework you use).
精彩评论