Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Death to WinZip

807605Jul 18 2007 — edited Jul 19 2007
I always thought that Java couldnt read or write WinZip
compatible zip files? Apparently you can.
Im too cheap to pay the $30 extortion fee to unlock WinZip and
WinRAR et al - so this makes me ask: Why hasnt anyone
written a Java un/zipper? Id pay them just to spite WinZip.

Im so happy I dont have to wait anymore for WinZip to vindictively count
to the number of zip files ive used since time began before it lets
me perform an operation.

If anyone wants to make a fancy GUI and get my $30 ill get you started:
import java.io.*;
import java.util.*;
import java.util.zip.*;

public class ZipLoader{

public static void main(String[] args){
	new ZipLoader();
}

public ZipLoader(){

	try{

	String zipFilename = "zipfile.zip";
	ZipFile zipFile = new ZipFile(zipFilename);
	Enumeration entries = zipFile.entries();

	while(entries.hasMoreElements()){
	ZipEntry entry = (ZipEntry)entries.nextElement();
	System.out.println("Entry: " + entry);
	}

	ZipEntry entry = zipFile.getEntry("textfile.txt");
	InputStream stream = zipFile.getInputStream(entry);
	InputStreamReader streamReader = new InputStreamReader(stream);

	BufferedReader reader = new BufferedReader(streamReader);
	String line;

	while((line = reader.readLine()) != null){
	System.out.println(line);
	}

	reader.close();
	stream.close();


	} catch(Exception e){
	e.printStackTrace();
	}

}


}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2007
Added on Jul 18 2007
8 comments
207 views