mercredi 27 septembre 2017

Get list of xml files from a jar on classpath

I have a Jar included within my project that is basically just contains several folders which contain xml files e.g.

folder1/subcategory/xmlfile.xml
folder2/subcategory/xmlfile.xml

The jar file shows on the classpath in Intellij.

I have set up a basic unit test to try and see if it works before implementing it in the main project.

@Test
public void shouldListFilesOnClasspath() throws Exception
{
    Reflections reflections = new Reflections("com.myproject", new ResourcesScanner());
    Set<String> xmlfiles = reflections.getResources(Pattern.compile(".*\\.xml"));
}

As I sort of expected the unit test returns xml files but only those in the resources folder.

Is there any way to get a list of xml files from the jar on the classpath?





Aucun commentaire:

Enregistrer un commentaire