lPsycongroo 2018-04-03 12:50 采纳率: 61.1%
浏览 762
已结题

liunx 下用命令压缩的文件不能在win下使用问题

求一个留liunx命令:加密压缩文件,这个文件可以在win下双击输入密码打开的,另外还有一个问题,

/**
* 使用指定密码将给定文件或文件夹压缩成指定的输出ZIP文件
* @param srcFile 需要压缩的文件或文件夹
* @param destPath 输出路径
* @param passwd 压缩文件使用的密码
/

public static void zip(String srcFile,String destPath,String passwd) {

AESEncrypter encrypter = new AESEncrypterBC();

AesZipFileEncrypter zipFileEncrypter = null;

try {

zipFileEncrypter = new AesZipFileEncrypter(destPath, encrypter);

/
*
* 此方法是修改源码后添加,用以支持中文文件名
/

zipFileEncrypter.setEncoding("utf8");

File sFile = new File(srcFile);

/
*
* AesZipFileEncrypter提供了重载的添加Entry的方法,其中:
* add(File f, String passwd)

* 方法是将文件直接添加进压缩文件
*

* add(File f, String pathForEntry, String passwd)
* 方法是按指定路径将文件添加进压缩文件
* pathForEntry - to be used for addition of the file (path within zip file)
*/

doZip(sFile, zipFileEncrypter, "", passwd);

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

zipFileEncrypter.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

    这个java压缩的不支持中文的问题,因为是用maven不能改源码,有办法支持中文吗
  • 写回答

3条回答 默认 最新

  • devmiao 2018-04-03 16:13
    关注

    windows下直接调用unrar就可以了,它是winrar带的一个解压缩dll。帮助文档有用法,或者google下也有。支持加密的zip。

    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题2
  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备