Rodrigo
Rodrigo

Reputation: 5139

How do I iterate through resource folder inside jar file?

In J2ME is there anything like

ResFolder resFolder = new ResFolder("/myFolder"); // or "/myfolder/*.png"
for (i=0; i<resFolder.count; i++] {
  img = Image.createImage(resFolder.fileName[i]);
}

?

I'm using a .txt with the name of the files to do that. Does anyone know if there's a more practical way to do it? Thanks!

Upvotes: 1

Views: 985

Answers (1)

Sam Ginrich
Sam Ginrich

Reputation: 851

There are two options.

1.) A jar file is a Zip file, contents can be enumerated, e.g. here List Contents Of Zip File Example

2.) A resource(folder) is technically an URL, which does not provide enumeration. But you may generate an index as resource /path/to/your/content/index.txt, which lists the content/files. So, from that index you can compose the resource URLs and access them.

Latter option works for jar and file repositories.

Upvotes: 1

Related Questions