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();
}
}
}