import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
public class Test {
String destPath = "D:\\tmp\\b.jar";
String sourcePath = "D:\\tmp\\a.jar";
/**
* @param args
*/
public static void main(String[] args) {
Test test = new Test();
try {
test.run();
} catch (IOException e) {
e.printStackTrace();
}
}
public void run() throws IOException {
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION,"1.0");
JarOutputStream target = new JarOutputStream(new FileOutputStream(destPath), manifest);
add(target);
target.close();
}
private void add(JarOutputStream target) throws IOException {
BufferedInputStream in = null;
try {
JarFile jarFile = new JarFile(sourcePath);
Enumeration<JarEntry> enu = jarFile.entries();
while (enu.hasMoreElements()) {
JarEntry oneEntry = enu.nextElement();
JarEntry entry = new JarEntry(oneEntry);
if (entry.getName().equalsIgnoreCase("META-INF/MANIFEST.MF")) {
continue;
}
target.putNextEntry(entry);
in = new BufferedInputStream(jarFile.getInputStream(oneEntry));
byte[] buffer = new byte[1024];
while (true) {
int count = in.read(buffer);
if (count == -1)
break;
target.write(buffer, 0, count);
}
target.closeEntry();
}
} finally {
if (in != null)
in.close();
}
}
}
分享到:
相关推荐
-m / --match-original is a new feature for apk analysis. This retains the apk is nearly original format, but will make rebuild more than likely not work due to ignoring the changes that newer aapt ...
* catalina-storeconfig.jar (Generation of XML configuration from current state) * catalina-tribes.jar (Group communication) * ecj-4.4.jar (Eclipse JDT Java compiler) * el-api.jar (EL 3.0 API) * jasper...
resolve bugs and/or add new features. No existing interface will be removed or changed although it may be deprecated. - org/apache/catalina/* - org/apache/catalina/comet/* Note: As Tomcat 7 matures, ...
The benefit of a column maker is that it can help you to format your text/code, or in some cases to make it easier to read in complex nested logic. Quick Open UltraEdit and UEStudio provide multiple ...
然后在Eclipse中通过File > New > Android Project,选择"Create project from existing source",指定项目名称为Settings,并设置源代码目录为/home/xxx/Settings。 由于导入的项目缺少依赖库,会出现错误。解决这...
蜂巢游戏N hive-core ( ) 的基于 playN ( ) GUI 实现。 目标是创建一个可用于与他人在线玩的功能性 gui,主要用于调试您自己的 AI(机器人)。...y - Change view theme (cycling between existing)
在Eclipse中,创建一个新的Android项目,选择"Import existing Android code into workspace",然后指向`frameworks\base\packages\Launchers`目录。注意,由于我们是导入源码而不是普通的Android项目,所以可能需要...
- 选择`from existing code`选项,设置工程名为`Phone2`。 - `Location`选择`~/workspace/Phone`。 - `Target Build`选择刚刚编译好的SDK。 - 点击`Finish`完成创建。 #### 步骤五:解决源码中的错误 1. **...
Ant是Apache软件基金会的一个项目,它是一个基于Java的构建工具,类似于Make,但设计更加面向Java开发者。Ant使用XML来描述构建过程,包括编译、测试、打包等任务。 在标题"eclipse基于ant自动化打包"中,我们关注...
Eclipse的“File” -> “Import” -> “Existing Projects into Workspace”选项可以轻松完成导入。 对于命令行用户,项目通常包含一个Makefile,这是一个自动化脚本,用于编译和构建项目。用户只需按照Makefile的...