• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read contents of jar file given specific path  RSS feed

 
Santhosh Raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All,
I have a jar file named "san.jar" with various folders like "classes", "resources", etc.,
Say for e.g i have a folder structure like "resources/assets/images" under which there are various images which I do not have any information about them like name of the images or number of images under the folder as the jar file is private and I am not allowed to unzip the jar.

OBJECTIVE: I need to get all the files under the given path without iterating over the whole jar file.

Right now what I am doing is iterating through each and every entry and whenever i come across .jpg file, I perform some operation.
Here for reading just the "resources/assets/images", I am iterating through the whole jarfile.



I know we can directly specify the file name and get the file. But as i told earlier, its private and I will not know any information about the files inside the jar and unpacking of jar is not allowed.
Can this be overriden by directly giving the "resources/assets/images" path and reading only that path from a jar file?
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santhosh Raj wrote:OBJECTIVE: I need to get all the files under the given path...


That's a reasonable objective.

... without iterating over the whole jar file.


But why is this part of the objective?
 
Santhosh Raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose, my jar is very huge with numerous classes and multimedia files, etc., and suppose if the images folder comes in the last during iterating, its a unnecessary task to iterate over unwanted items and also a costly task wheni t comes to performance aspect.
Hope you got my point!!
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santhosh Raj wrote:Suppose, my jar is very huge with numerous classes and multimedia files, etc., and suppose if the images folder comes in the last during iterating, its a unnecessary task to iterate over unwanted items and also a costly task wheni t comes to performance aspect.
Hope you got my point!!


Actually, no. It costs you almost nothing to skip over those jar entries which you don't need to look at. Have you measured these so-called costs or are you just indulging in some premature optimization?
 
Santhosh Raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have calculated the time by iterating through the whole jar file and also reading just the contents which I want directly by specifying their names.
It takes noticeable amount of time which I should overcome.
And also, its the requirement that I should not iterate through the whole jar file.
So is there any mechanism to achieve the same?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!