org.sape.carbon.core.util.jar
Class JarEntryOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.ByteArrayOutputStream
|
+--org.sape.carbon.core.util.jar.JarEntryOutputStream
- public class JarEntryOutputStream
- extends ByteArrayOutputStream
An output stream that is used by EnhancedJarFile to write entries to a jar.
This implementation uses a ByteArrayOutputStream to buffer the output
until the stream is closed. When the stream is closed, the output is written
to the jar.
Copyright 2002 Sapient
- Since:
- carbon 1.0
- Version:
- $Revision: 1.9 $($Author: dvoet $ / $Date: 2003/05/05 21:21:23 $)
- Author:
- Douglas Voet, April 2002
Method Summary |
void |
close()
Closes the stream and writes entry to the jar |
private void |
writeToJar()
Writes the entry to a the jar file. |
jar
private EnhancedJarFile jar
jarEntryName
private String jarEntryName
JarEntryOutputStream
public JarEntryOutputStream(EnhancedJarFile jar,
String jarEntryName)
- Constructor
- Parameters:
jar
- the EnhancedJarFile that this instance will write tojarEntryName
- the name of the entry to be written
close
public void close()
throws IOException
- Closes the stream and writes entry to the jar
- Overrides:
close
in class ByteArrayOutputStream
IOException
writeToJar
private void writeToJar()
throws IOException
- Writes the entry to a the jar file. This is done by creating a
temporary jar file, copying the contents of the existing jar to the
temp jar, skipping the entry named by this.jarEntryName if it exists.
Then, if the stream was written to, then contents are written as a
new entry. Last, a callback is made to the EnhancedJarFile to
swap the temp jar in for the old jar.
IOException
Copyright 1999-2003 Sapient Corporation. All Rights Reserved.