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();
}
}
}
分享到:
相关推荐
Add new HDD to the existing raid by WEBBIOS
a Change to an Existing Device Guidance for Industry and Food and Drug Administration Staff Document issued on October 25, 2017. The draft of this document was issued on August 8, 2016. This ...
For environments where class instrumentation is required but are not supported by the existing LoadTimeWeaver implementations, a JDK agent can be the only solution. For such cases, Spring provides ...
510(k) for a Software Change to an Existing Device ______________________________________________________________________________ Guidance for Industry and Food and Drug Administration Staff ...
The transition from a reference rate regime centred on interbank offered rates (IBORs) to one based on a new set of overnight risk-free rates (RFRs) is an important paradigm shift for markets....
Most existing methods require pre-defining a set of types and training a multi-class classifier from a large labeled data set based on multi-level linguistic features. They are thus limited to ...
一下为部分题目: 2. The String.Format(“Input = {0} and Output = {1}”, “1”,”2”) expression returns which of ...6. Which activity can be used to modify the value of an existing cell in a DataTable?
Existing Code shows how refactoring can make object-oriented code simpler and easier to maintain. Today refactoring requires considerable design know-how, but once tools become available, all ...
Dex2Jar 插件 Dex2Jar 的 Eclipse 插件。 原始项目来源: : 构建 Dex2Jar 改编自: : git clone git@github.... > Plug-in Development > Plug-in from Existing JAR Archives > Next > Add Extern
four-component analysis framework for platoon systems from a networked control perspective, including a literature review by network awareness, unified models of key components, and two application ...
Learn how to make double-sided professional-quality PCBs from the ground up using EAGLE--the powerful, flexible design software. In this step-by-step guide, electronics guru Simon Monk leads you ...
fastjson 的最新jar包 Fastjson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. ...
The goal is to be able to port existing Tcl code bases that use Expect directly to Java without changes. The current version has successfully run a 10,000 line Tcl script which heavily depends on ...
For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true ...
A Survey on Existing MPSoCs Architecture
you will learn about the Drupal theming architecture and the PHPTemplate engine, and then move on to modifying existing themes and building new themes from scratch. You will find out about tools to ...
Send Selected Files from a Zip file by email or to a new Zip file • New! Resize Photos from a Zip file when sending by email or to a new Zip file • Explorer View displays image thumbnails for easy ...
Compared to existing dc circuit breakers, the z-source breaker features fast turn-off, simple control, and the source does not experience the fault current. The operation and analysis of the new ...
invoke a command from a shell, the corresponding program is executed in a new process; the shell process resumes when that process completes. Advanced programmers often use multiple cooperating ...
Recognizing Walls From an Existing Part Extruding Isolating Walls Creating Rolled Walls Creating Bends on Walls Manually Creating Bends from Walls Generating Bends Automatically Creating Conical Bends...