This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Get the Size of files inside a WAR file of a EAR File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Get the Size of files inside a WAR file of a EAR File" Watch "Get the Size of files inside a WAR file of a EAR File" New topic
Author

Get the Size of files inside a WAR file of a EAR File

Shaik Riyaz
Greenhorn

Joined: Apr 17, 2008
Posts: 7
Hello,

Iam developing a utility to compare Jar/EAR/WAR Files.

I am facing an issue while comapring EAR files i.e. I am able to get the sizes of files inside EAR file including WAR File , But I want to be able to iterate the WAR file (which is present inside EAR) and get sizes of files inside it.

The above funtionality would enable users to identify the file inside WAR file of a EAR file which has changed.

Please find below the code Iam using to get the contents and as can be seen I am able to get file name and file date timestamp of files inside WAR file but not the sizes.

Please let me know your thoughts regarding the approach which can be adopted.

Thanks in advance !!


Current Output:
In EAR comparision
OUTSIDE WAR FILE NAME:META-INF/MANIFEST.MF FILE SIZE:[ 25 ] FILE Time: [ 09/27/2012 09:56:48 PM ]
OUTSIDE WAR FILE NAME:META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml FILE SIZE:[ 1348 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:META-INF/application.xml.20120405-163700.bak FILE SIZE:[ 833 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:META-INF/application.xml FILE SIZE:[ 833 ] FILE Time: [ 08/30/2012 01:56:54 PM ]
OUTSIDE WAR FILE NAME:project.pj FILE SIZE:[ 527 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:META-INF/ibm-application-bnd.xmi FILE SIZE:[ 835 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:deployment.xml.20120409-125442.bak FILE SIZE:[ 2458 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
In WAR comparision
WAR FILE NAME:samplewebapp.war
WAR FILE SizE:292765
WAR FILE Time:09/27/2012 09:56:48 PM
INSIDE WAR FILE NAME:samplewebapp.war/META-INF/MANIFEST.MF FILE SIZE: [ -1-1-1 ] FILE Time: [ 09/27/2012 09:56:48 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/sample.jsp FILE SIZE: [ -1-1-1 ] FILE Time: [ 08/30/2012 01:56:44 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/WEB-INF/ibm-web-bnd.xmi FILE SIZE: [ -1-1-1 ] FILE Time: [ 08/30/2012 01:56:52 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/xsl/sample.xsl FILE SIZE: [ -1-1-1 ] FILE Time: [ 08/30/2012 01:56:38 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/xsl/sample.xsl FILE SIZE: [ -1-1-1 ] FILE Time: [ 08/30/2012 01:56:46 PM ]

Needed Output:
In EAR comparision
OUTSIDE WAR FILE NAME:META-INF/MANIFEST.MF FILE SIZE:[ 25 ] FILE Time: [ 09/27/2012 09:56:48 PM ]
OUTSIDE WAR FILE NAME:META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml FILE SIZE:[ 1348 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:META-INF/application.xml.20120405-163700.bak FILE SIZE:[ 833 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:META-INF/application.xml FILE SIZE:[ 833 ] FILE Time: [ 08/30/2012 01:56:54 PM ]
OUTSIDE WAR FILE NAME:project.pj FILE SIZE:[ 527 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:META-INF/ibm-application-bnd.xmi FILE SIZE:[ 835 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
OUTSIDE WAR FILE NAME:deployment.xml.20120409-125442.bak FILE SIZE:[ 2458 ] FILE Time: [ 08/30/2012 01:56:24 PM ]
In WAR comparision
WAR FILE NAME:samplewebapp.war
WAR FILE SizE:292765
WAR FILE Time:09/27/2012 09:56:48 PM
INSIDE WAR FILE NAME:samplewebapp.war/META-INF/MANIFEST.MF FILE SIZE: [ 25 ] FILE Time: [ 09/27/2012 09:56:48 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/sample.jsp FILE SIZE: [ 35733 ] FILE Time: [ 08/30/2012 01:56:44 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/WEB-INF/ibm-web-bnd.xmi FILE SIZE: [ 1411 ] FILE Time: [ 08/30/2012 01:56:52 PM ]
INSIDE WAR FILE NAME:samplewebapp.war/xsl/sample.xsl FILE SIZE: [ 22912 ] FILE Time: [ 08/30/2012 01:56:38 PM ]


Venkata Sirish
Ranch Hand

Joined: Apr 09, 2007
Posts: 112
Try closing the ZipEntry using zis.closeEntry(); before line 47.

Hope this helps!

Shaik Riyaz
Greenhorn

Joined: Apr 17, 2008
Posts: 7
The above issue has been resolved. I had to close the zip entry while iterating for file sizes of files inside WAR file of a EAR file.

Shaik Riyaz
Greenhorn

Joined: Apr 17, 2008
Posts: 7
yeah Thanks for the reply the sollution worked
 
 
subject: Get the Size of files inside a WAR file of a EAR File