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 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝