How To Unzip Large File With Java

import java.io.*;
import java.util.zip.*;

public class UnZip {
   final static int BUFFER = 2048;
   
  // "/home/admin/Downloads/movies/stockv2@ingram.zip"
   public String unzipFile(String compressFilePath, String uncompressFolderPath){
	   
	   String uncompressedFilePath=null;
	   
	   try {
	         BufferedOutputStream dest = null;
	         FileInputStream fis = new   FileInputStream(compressFilePath);
	         ZipInputStream zis = new     ZipInputStream(new BufferedInputStream(fis));
	         ZipEntry entry;
	         while((entry = zis.getNextEntry()) != null) {
	        	 uncompressedFilePath=uncompressFolderPath+entry.getName();
	        	 System.out.println("Extracting: " +entry);
	            int count;
	            byte data[] = new byte[BUFFER];
	            // write the files to the disk
	            FileOutputStream fos = new 
		      FileOutputStream(uncompressedFilePath);
	            dest = new 
	              BufferedOutputStream(fos, BUFFER);
	            while ((count = zis.read(data, 0, BUFFER)) 
	              != -1) {
	               dest.write(data, 0, count);
	            }
	           
	            
	            dest.flush();
	            dest.close();
	         }
	         zis.close();
	      } catch(Exception e) {
	         e.printStackTrace();
	      }
	  
	   
	   
	   System.err.println(uncompressedFilePath);
	   
	   return uncompressedFilePath;
	   
   }
   
   
   public static void main (String argv[]) {
      
	   //String destinationPath="/home/admin/Downloads/movies/";
	   
	   
	   UnZip unZip = new UnZip();
	   System.out.println(unZip.unzipFile("/home/admin/Downloads/movies/stockv2@ingram.zip","/home/admin/Downloads/movies/"));	   
	   
   }	   
}
Advertisements

About lorddisk

WebCenter Content, WebCenter Portal, WebCenter Sites,Weblogic, Identity and Access Management (IAM),SSO,OAM,OIM,OAAM,OUD, OPAM,OID, OVD ,Oracle API Gateway ,OBIEE,OEDQ, Oracle ADF, Oracle SOA,J2EE, CackePHP ,PHP,J2SE,J2EE,Spring,Hibernate,JQuery,CSS,Java Script ,Joomla,Drupal,Worpress
This entry was posted in java and tagged , , . Bookmark the permalink.

One Response to How To Unzip Large File With Java

  1. Swift Maxwell says:

    In the topic u mentioned large files.
    Can I know the limit that this program will work correctly?
    Because I need to retract a 25GB file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s