Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Read contents of jar file given specific path

 
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?
 
Marshal
Posts: 25682
69
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
Marshal
Posts: 25682
69
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?
 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic