Posted By

Caliban on 11/29/06


Tagged

file zip FileOutputStream


Versions (?)

Extract ZipEntry into a FileOutputStream


 / Published in: Java
 

  1. import java.io.FileInputStream;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileOutputStream;
  4. import java.io.IOException;
  5. import java.util.zip.InflaterInputStream;
  6. import java.util.zip.ZipEntry;
  7. import java.util.zip.ZipInputStream;
  8.  
  9.  
  10. public class ZipInputStreamTest
  11. {
  12.  
  13. /**
  14.   * @param args
  15.   * @throws IOException
  16.   */
  17. public static void main( String[] args ) throws IOException
  18. {
  19. FileInputStream file = new FileInputStream( "I:\\Mitarbeiter\\Mai\\Software\\anleitung_xmw_grdsa.zip" );
  20. ZipInputStream zip_inputstream = new ZipInputStream( file );
  21.  
  22. ZipEntry current_zip_entry = null;
  23.  
  24. while( ( current_zip_entry = zip_inputstream.getNextEntry() ) != null )
  25. {
  26. System.out.println( current_zip_entry.getName() );
  27. FileOutputStream outputfile = new FileOutputStream( "C:\\" + current_zip_entry.getName() );
  28.  
  29. int data = 0;
  30. while( ( data = zip_inputstream.read() ) != - 1 )
  31. {
  32. outputfile.write( data );
  33. }
  34.  
  35. outputfile.close();
  36. }
  37.  
  38. zip_inputstream.close();
  39. file.close();
  40. }
  41.  
  42. }

Report this snippet  

You need to login to post a comment.