1 22 package org.objectweb.petals.tools.jbiplugin; 23 24 import java.io.DataInputStream ; 25 import java.io.File ; 26 import java.io.FileInputStream ; 27 import java.util.zip.ZipEntry ; 28 import java.util.zip.ZipOutputStream ; 29 30 35 public abstract class PackageAbstractMojo extends JBIAbstractMojo { 36 37 44 protected File jbiDirectory; 45 46 57 protected void recurseDirectory(ZipOutputStream zipOutputStream, 58 File directory, String entryDirectoryName) throws Exception { 59 for (File file : directory.listFiles()) { 60 if (file.isFile()) { 61 if (verbose) { 62 System.out.println(" " 63 + entryDirectoryName + File.separator + file.getName() + " added to JBI Service Assembly archive"); 64 } 65 ZipEntry zipEntry = new ZipEntry (("".equals(entryDirectoryName)) ? file.getName() : (entryDirectoryName 66 + File.separator + file.getName())); 67 DataInputStream dis = new DataInputStream ( 68 new FileInputStream (file)); 69 byte[] content = new byte[dis.available()]; 70 dis.readFully(content); 71 zipOutputStream.putNextEntry(zipEntry); 72 zipOutputStream.write(content); 73 zipOutputStream.closeEntry(); 74 } else { 75 if (!file.getName().startsWith(".")) { 76 recurseDirectory(zipOutputStream, file, ("".equals(entryDirectoryName)) ? file.getName() : (entryDirectoryName 78 + File.separator + file.getName())); 79 } 80 } 81 } 82 } 83 } 84 | Popular Tags |