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/"));	   
	   
   }	   
}

Jsp Tutrial


Java Control in Scriptlets
bullet If Statement
bullet Switch Statement
bullet For Statement
bullet Try Statement

Implicit Object application
bullet Get Initialization Parameters
bullet Set Attribute
bullet Get Attributes
bullet Remove Attribute

Implicit Object config
bullet Get Initialization Parameters
bullet Initialization and Destruction

Implicit Object exception
bullet Exception

Implicit Object out
bullet Print Output

Implicit Object pageContext
bullet Set/Remove Page Attribute
bullet Set/Remove Scoped Attribute
bullet Get Scoped Attributes
bullet Get Attribute Scope
bullet Remove Attribute in All Scopes
bullet Error Data
JSP Declarations
bullet Instance Variable
bullet Method

Implicit Object request
bullet Set/Remove Attribute
bullet Get Attributes
bullet Get Parameters by Name
bullet Get Parameters from Map
bullet Get Headers
bullet Get Special Headers
bullet Get Cookies
bullet Get HTTP Information
bullet Get Locales
bullet Get Server Information
bullet Get Miscellaneous Information

Implicit Object response
bullet Set Headers
bullet Add Cookie
bullet Set Status
bullet Send Error
bullet Send Redirect

Implicit Object session
bullet Set Attribute
bullet Get Attributes
bullet Remove Attribute
bullet Get Miscellaneous Information
bullet Set Maximum Inactive Interval
bullet Encode URL
bullet Encode URL & Send Redirect
bullet Invalidate

Understanding and Extending Java ClassLoader

The Java ClassLoader is one of the crucial but rarely used components of Java in Project Development. Personally I have never extended ClassLoader in any of my projects but the idea of having my own ClassLoader that can customize the Java Class Loading thrills me.

This article will provide an overview of Java Class Loading and then move forward to create a custom ClassLoader and use it.

What is a ClassLoader?

We know that Java Program runs on Java Virtual Machine (JVM). When we compile a Java Class, it transforms it in the form of bytecode that is platform and machine independent compiled program and store it as a .class file. After that when we try to use a Class, Java ClassLoader loads that class into memory.

 

original post here

What Is the Anti-IF Campaign?

What Is the Anti-IF Campaign?

The goal of the Anti-IF Campaign is to raise awareness of effective use of the Object-Oriented Paradigm, first of all removing bad, dangerous IFs.

The Campaign accomplishes this by:

Continue reading What Is the Anti-IF Campaign?

Spring framework without XML… At all!

First, there was EJB 2.1 with countless XML files all over. It won’t be such a big exaggeration to say that for every line of business code you had to create at least 10 lines of framework code and two pages of XML. Local and remote interfaces, manual JNDI lookup, triply nested try-catches, checked RemoteExceptions everywhere… this was enterprise. There were even tools to generate some of this boilerplate automatically.
Then couple of guys came and created Spring framework. After being forced to cast by obscure PortableRemoteObject.narrow() it was like taking a deep breath of fresh air, like writing poetry after working in coal mine. Time went by (BTW do you remember how many years ago was the last major JRE release?) and Sun learnt their lesson. EJB 3.0 was even simpler compared to Spring, XML-free, annotations, dependency injection. 3.1 was another great step toward simplicity, being more and more often compared to Spring. Logically current state of the art EJB specification might be considered as a subset of what Spring offers, I am actually surprised why there is no EJB spec. implementation in plain Spring (oh, wait…), considering its out-of-the-box support for JPA 1.0/2.0, JSR-250, JSR-330, JAX-WS/RS compatible solutions and others. But even though, Spring framework is nowadays perceived as a slow, heavyweight and hard to maintain, mainly due to reliance on XML descriptors. Once simple, now Spring is a whipping boy in the JEE framework battle.
I don’t like politics, I won’t defend my beloved framework writing lengthy essays. Instead I will take simple, but not trivial Spring application and quickly rewrite it so that it won’t use XML. Not reduce the amount of XML, not leave only few untouchable lines. No XML – at all.
For the purposes of this article I created very simple Spring web application (base version under xml branch, final on master on my GitHubaccount) using JDBC, JMS and JMX, just not to make things trivial. Every change I made to the source code will be reflected in a separate commit to this repository. Step by step I will be removing XML configuration until there will be no Spring XML left. This is where we start: Continue reading Spring framework without XML… At all!