Java examples for File Path IO:Zip File
Extract First File From Zip File
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { /*from ww w . ja v a 2 s. c om*/ public static void main(String args[]) { String sourceZipFile = "C:/Folder/sourceFile.zip"; try { FileInputStream fin = new FileInputStream(sourceZipFile); ZipInputStream zin = new ZipInputStream(fin); ZipEntry entry = zin.getNextEntry(); OutputStream os = new FileOutputStream("c:/extractedFile.css"); byte[] buffer = new byte[1024]; int length; while( (length = zin.read(buffer)) > 0) { os.write(buffer, 0, length); } os.close(); zin.close(); System.out.println("File Extracted from zip file"); } catch(IOException e) { System.out.println("IOException :" + e); } } }