ZiP file encryption

Source: Internet
Author: User

It has been a long time to find out what the customer needs to achieve, ZIP folder decryption, and functions, and this information is really scarce. Post the source code to share with you.


Package com. hongan. test;

Import java. io. File;

Import android. app. Activity;
Import android. OS. Bundle;
Import android. util. Log;
Import android. view. View;
Import android. view. View. OnClickListener;
Import android. widget. Button;

Public class PassWordZipDemoActivity extends Activity {
/** Called when the activity is first created .*/

Button btn_jiemi, btn_jiami;
ZipFileWithPassword zipFileWithPassword;
String filePath;
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );


Btn_jiemi = (Button) this. findViewById (R. id. jiemi );
Btn_jiami = (Button) this. findViewById (R. id. jiami );
ZipFileWithPassword = new ZipFileWithPassword ();
Filepathappszipfilewithpassword.zip Dir;

Btn_jiemi.setOnClickListener (new OnClickListener (){
Public void onClick (View v ){
// TODO Auto-generated method stub
ZipFileWithPassword = new ZipFileWithPassword ();
ZipFileWithPassword. newFolder ();
ZipFileWithPassword. TestDecryptZipFile ();
}
});
Btn_jiami.setOnClickListener (new OnClickListener (){
Public void onClick (View v ){
// TODO Auto-generated method stub
ZipFileWithPassword. TestEncryptZipFile ();
File file = new File (filePath );
Log. I ("infor", "filePath is" + filePath );

DeleteFile (file );
// File. delete ();

}
}); Www.2cto.com
}
Private void deleteFile (File file ){
If (file. exists ()){
If (file. isFile ()){
File. delete ();
} Else if (file. isDirectory ()){
File files [] = file. listFiles ();
For (int I = 0; I <files. length; I ++ ){
This. deleteFile (files [I]);
}
}
File. delete ();
} Else {
Log. I ("infor", "the deleted file does not exist! "+ '\ N ');
}
}
}

Demo source code

 


 

Author: awp258

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.