[英]Removing a ZIP/JAR file comment
When I run an obfuscator like allatori
on my JAR
file, it will add a comment to the archive saying something like Obfuscation by Allatori Obfuscator http://www.allatori.com
当我在我的JAR
文件上运行像allatori
这样的混淆allatori
时,它会在存档中添加一条评论,说类似于Obfuscation by Allatori Obfuscator http://www.allatori.com
Using WinRAR
, this comment can be removed by editing the archive comment.使用WinRAR
,可以通过编辑存档注释来删除此注释。
However, I did not find a way to do this in a batch script or Java code to integrate into my build process.但是,我没有找到在批处理脚本或 Java 代码中执行此操作以集成到我的构建过程中的方法。
How can it be done?怎么做到呢?
This is how Archive File comments can be updated using WinRAR CLI:这是使用 WinRAR CLI 更新存档文件注释的方式:
for %I in ("E:\YOUR\JAR\LOCATION\*.jar") do @"%ProgramFiles%\WinRAR\WinRAR.exe" c -zBLANK_COMMENT_FILE.txt "%I"
Create one blank file named BLANK_COMMENT_FILE.txt
where you run this command.创建一个名为BLANK_COMMENT_FILE.txt
空白文件,您可以在其中运行此命令。
Run this command with administrator access.以管理员权限运行此命令。
Hope this will help you.希望这会帮助你。
I guess you could copy the zip file without copying the comment.我猜你可以复制 zip 文件而不复制评论。
public static void removeComment(Path file) throws IOException {
Path tempFile = Files.createTempFile("temp", ".zip");
copyZipFile(file, tempFile, false);
Files.move(tempFile, file, StandardCopyOption.REPLACE_EXISTING);
}
public static void copyZipFile(Path file, Path newFile, boolean copyComment) throws IOException {
try (ZipFile zipFile = new ZipFile(file.toFile());
ZipOutputStream outputStream = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(newFile)))) {
if (copyComment) {
outputStream.setComment(zipFile.getComment());
}
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
copyEntry(zipFile, outputStream, entries.nextElement());
}
}
}
private static void copyEntry(ZipFile zipFile, ZipOutputStream outputStream, ZipEntry entry) throws IOException {
ZipEntry newEntry = (ZipEntry) entry.clone();
outputStream.putNextEntry(newEntry);
IOUtils.copy(zipFile.getInputStream(entry), outputStream);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.