1 5 package SOFA.SOFAnode.TR.Impl; 6 7 import java.io.File ; 8 import java.io.FileInputStream ; 9 import java.io.IOException ; 10 import java.io.OutputStream ; 11 import java.util.Enumeration ; 12 import java.util.Hashtable ; 13 import java.util.jar.JarEntry ; 14 import java.util.jar.JarOutputStream ; 15 16 import SOFA.Util.Tools; 17 18 23 class BundleOutputStream extends JarOutputStream { 24 25 30 public BundleOutputStream (OutputStream out) throws IOException { 31 super(out); 32 } 33 34 39 public void putNextBundleEntry (BundleEntry be) throws IOException { 40 Hashtable files = be.getFiles().getFiles(); 41 42 Enumeration paths = files.keys(); 43 while (paths.hasMoreElements()) { 44 String path = (String ) paths.nextElement(); File file = (File ) files.get(path); long fileLength = file.length(); 47 48 path = path.replace('\\', '/'); JarEntry jarEntry = new JarEntry (be.getName() + path); jarEntry.setSize(fileLength); 51 jarEntry.setTime(file.lastModified()); putNextEntry(jarEntry); 53 54 FileInputStream fileStream = new FileInputStream (file); 55 56 Tools.copyStream(fileStream, this); 57 58 fileStream.close(); 59 closeEntry(); 60 } 61 } 62 63 } 64 | Popular Tags |