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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?