This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Unzip

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..
I have a zip file which comes from DB as a blob and I need to check the contents of the files after unzipping.The checks I need to make are..
1) The zip file should not contain more than one file in it
2)The file inside the zip file should be in a particular extension( like .xml or xls).
Am using servlets to get the data from the DB perform all these operations.
Any inputs as to how to procees will be helpful
Thx
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mary,
It seems to me that you have the Servlet part already figured out. So I think I will move this to the IO and Streams forum so those experts can handle your specific needs regarding Zipped files, extensions, etc.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mary !
the following shows how to unzip the a zip file, get the file names etc. It will help you.the classes you need are in java.util.zip.*;
when you get the zip file from the DB,create a zip file as follows:
ZipFile zipfile = new Zipfile(filename);
then: get the entries in the zip file:
Enumeration entries = zipfile.entries();
then you can go through all of them
while(entries.hasMoreElements())
{
//get the entry
ZipEntry entry = (ZipEntry)entries.nextElement();
//get file name
String name = entry.getName();

//parse the name
if(name.substring(..)){}
//OR
StringTokenizer st = new StringTokenizer(name,".");
----- so on-----
}//end while
Hope that helps

-Sri
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic