JarUtilspublic class JarUtils extends Object A collection of jar utilities |
Fields Summary |
---|
private static final Logger | log |
Methods Summary |
---|
public static java.lang.String[] | addJar(java.util.jar.JarOutputStream outputStream, java.lang.String prefix, java.io.File jar)Add jar contents to the deployment archive under the given prefix
log.trace("addJar: " + jar);
ArrayList tmp = new ArrayList();
FileInputStream fis = new FileInputStream(jar);
JarInputStream jis = new JarInputStream(fis);
JarEntry entry = jis.getNextJarEntry();
while (entry != null)
{
if (entry.isDirectory() == false)
{
String entryName = prefix + entry.getName();
tmp.add(entryName);
addJarEntry(outputStream, entryName, jis);
}
entry = jis.getNextJarEntry();
}
jis.close();
String[] names = new String[tmp.size()];
tmp.toArray(names);
return names;
| public static void | addJarEntry(java.util.jar.JarOutputStream outputStream, java.lang.String entryName, java.io.InputStream inputStream)Add a jar entry to the deployment archive
log.trace("addJarEntry: " + entryName);
outputStream.putNextEntry(new JarEntry(entryName));
copyStream(outputStream, inputStream);
| public static void | copyStream(java.io.OutputStream outputStream, java.io.InputStream inputStream)Copies the input stream to the output stream
byte[] bytes = new byte[4096];
int read = inputStream.read(bytes, 0, 4096);
while (read > 0)
{
outputStream.write(bytes, 0, read);
read = inputStream.read(bytes, 0, 4096);
}
|
|