Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
reply
    Bookmark Topic Watch Topic
  • New Topic