Wie kann ich folgende Klasse in meinem Programm nutzen ?
Java:
import java.io.*;
import java.util.*;
import java.util.jar.*;
public class JarExtract {
public static void main(String[] args) throws IOException {
// Get the jar name and the entry name.
String jarName = args[0];
String entryName = args[1];
// Open the jar.
JarFile jar = new JarFile(jarName);
try {
// Get the entry and its input stream.
JarEntry entry = jar.getJarEntry(entryName);
// If the entry is not null, extract it. Otherwise, print a
// message.
if (entry != null) {
// Get an input stream for the entry.
InputStream entryStream = jar.getInputStream(entry);
try {
// Create the output file (clobbering the file if it exists).
FileOutputStream file = new FileOutputStream(entry.getName());
try {
// Allocate a buffer for reading the entry data.
byte[] buffer = new byte[1024];
int bytesRead;
// Read the entry data and write it to the output file.
while ((bytesRead = entryStream.read(buffer)) != -1) {
file.write(buffer, 0, bytesRead);
}
} finally { file.close(); }
} finally { entryStream.close(); }
} else { } // end if
} finally { jar.close(); }
}
}