unzip file yang menggunakan password pada java

Berputar2 mencari2

q> Bismillah
q> Library yang digunakan untuk meng-extract (unzip) file yang di password adalah zip4j

q> donlod jar nya pada http://www.lingala.net/zip4j/index.php
q> ato bagi projectnya menggunakan maven bisa menambahkan repo maven


<dependency>
 <groupId>net.lingala.zip4j</groupId>
 <artifactId>zip4j</artifactId>
 <version>1.3.1</version>
 </dependency>

q> ayu lakasi ka coding ,
q> let’s to code ,
q> ndang nang coding ,
q> hayya ila coding

q> Code for ZK,🙂


@Command
 public void getUploadedFile(@BindingParam("media") Media media) {

MstConfig zip = getMasterFacade().getMstConfigDao().findById("ZIP_DIR");
MstConfig extracted = getMasterFacade().getMstConfigDao().findById("EXT_DIR");

 if (media != null){
 try {
 File dst = new File(zip.getNilai()+media.getName());
 String ctype = media.getContentType();

 Files.copy(dst, media.getStreamData());
 if (ctype.equalsIgnoreCase("application/zip")){
 ZipParameters zipParam = new ZipParameters();
 try{
 ZipFile file = new ZipFile(dst);
 if (file.isEncrypted()){
 file.setPassword("IniPaswotNangNgalihBanar");
 }
 file.extractAll(extracted.getNilai());
 Messagebox.show("File \n"+file.getFile().getAbsoluteFile()+"\nExtract "+extracted.getNilai());
 }catch (Exception e) {
 // TODO: handle exception
 e.printStackTrace();
 }

 } else {
 Messagebox.show("Format file salah, file yang dianjurkan .zip");
 return;
 }

 } catch (IOException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
 }
 }else{
 Messagebox.show("tidak ada");
 }

}

q> Selesai,,
q> Alhamdulillah

Published by

saifiahmada

Begin a big Process with a bit trying

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