java - Enumerate all files of certain type from resources -


I have a JAR file that contains the resource section of my Jeanelpi file I There are a lot of images in subfolders

The user should be able to replace this jar file later / enable / add / remove images.

There is a way to calculate all the files from the resources, with the help of the .if files as the file extension or even better "images / * .gif" a pattern To specify (so I just get the picture which "pictures" as their original directory).

The second option would be to write a text file that shows the file structure. In this way you can run through the line through the image through the image, but it will mean that you have to update two places and it is not very user-friendly.

Yes, you just count the files inside move to grab the jar directory: < Pre> public string [] getFiles () throws IOException {of ArrayList & lt; String & gt; List = New Arrestist & lt; String & gt; (); & Lt; JarEntry & gt; Ents = new Array list & lieutenant; Greentree & gt; (); Calculation & LT; JarEntry & gt; E = null; Url jarap = found place (); If (jarp! = Null) {jar = jarp.getProtocol (). Equal ignoreCase ("jar")? Zarp: New URL ("Jar:" + jarp.toString () + "! /"); Jarfile garg = null; try {Jarf = AccessController.doPrivileged (New PrivilegedExceptionAction & LT; JarFile & gt; () {@Override public JarFile runs (throws Exception {JarURLConnection Conn = (JarURLConnection) jar.openConnection ()); conn.setUseCaches (false); return Conn.getJarFile ();}}); } Hold (PrivilegedActionException Pre) {Logger.getLogger (LicenseLoader.class.getName ()) Log in (Level.SEVERE, null, pre). } E = jarf.entries (); While (e.hasMoreElements ()) {JarEntry je = e.nextElement (); If (! Je.isDirectory ()) {ents.add (j); }} {JarEntry ENT: for father} {if. (Ent.getName () startsWith (path)) & amp; (ent.getName () endsWith (".gif")) {string name = ENT GetName () Replace (pathname, ""); List.add (name); }}} Return list. Arrow (new string [list.size ()]); }

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -