📄 archivebuilder.java
字号:
package org.jbpm.par;
import java.io.*;
import java.util.jar.*;
import org.apache.commons.logging.*;
import org.jbpm.util.io.*;
import org.jbpm.model.definition.impl.*;
public class ArchiveBuilder {
private ByteArrayOutputStream byteStream = null;
private JarOutputStream archiveStream = null;
public ArchiveBuilder( InputStream processDefinitionXmlInputStream ) throws IOException {
byteStream = new ByteArrayOutputStream();
archiveStream = new JarOutputStream( byteStream );
add( "processdefinition.xml", processDefinitionXmlInputStream );
}
public ArchiveBuilder( DefinitionImpl definition ) throws IOException {
// TODO : create an archive from a DefinitionImpl
throw new UnsupportedOperationException( "creating an archive from a DefinitionImpl is not yet supported. Please, contribute this functionality :-)" );
}
public void add( String entryName, InputStream fileStream ) throws IOException {
JarEntry jarEntry = new JarEntry( entryName );
archiveStream.putNextEntry( jarEntry );
IoUtil.transfer( fileStream, archiveStream );
archiveStream.closeEntry();
}
public void add( String entryName, byte[] bytes ) throws IOException {
add( entryName, new ByteArrayInputStream( bytes ) );
}
public byte[] getArchiveBytes() throws IOException {
archiveStream.flush();
archiveStream.close();
return byteStream.toByteArray();
}
public JarInputStream getJarInputStream() throws IOException {
return new JarInputStream( new ByteArrayInputStream( getArchiveBytes() ) );
}
public void save( String fileName ) throws IOException {
OutputStream fileStream = new FileOutputStream( fileName );
IoUtil.transfer( new ByteArrayInputStream( getArchiveBytes() ), fileStream );
}
private static Log log = LogFactory.getLog(ArchiveBuilder.class);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -