AesZipFileEncrypter zipAndEncrypt方法将所有文件夹树添加到文件 [英] AesZipFileEncrypter zipAndEncrypt method adds all folder tree to file
本文介绍了AesZipFileEncrypter zipAndEncrypt方法将所有文件夹树添加到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用这种方法来压缩和解密文件:
AesZipFileEncrypter.zipAndEncrypt
I'm using this method to zip and decrypt a file: AesZipFileEncrypter.zipAndEncrypt
此代码:
AesZipFileEncrypter.zipAndEncrypt(new File("C:\Test\Folder\MyFile.txt"), new File("C:\Test\Folder\MyZip.zip"), password, aesEncrypter);
还会压缩文件的文件夹树,而不仅仅是文件。例如:
在创建的zip文件中添加C:\Test\Folder\MyFile.txt我也可以找到文件夹C:\Test\Folder\MyFile.txt。在根文件夹中只有MyFile.txt。
可能吗?
compresses also the folder tree of my file, not just the file. For example: Adding C:\Test\Folder\MyFile.txt in the created zip file I will find the folders C:\Test\Folder\MyFile.txt also if I would like to have just MyFile.txt in the root folder. Is it possibile?
推荐答案
这是解决方案:
AESEncrypter aesEncrypter = new AESEncrypterBC();
aesEncrypter.init(password, 0);
AesZipFileEncrypter ze=new AesZipFileEncrypter(outputfilename, aesEncrypter);
ze.add(inputfilename,new FileInputStream(inputfilename), password);
ze.close();
这篇关于AesZipFileEncrypter zipAndEncrypt方法将所有文件夹树添加到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文