Package generic.io

Class JarWriter


  • public class JarWriter
    extends java.lang.Object
    JarWriter is a class for writing to a jar output stream.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.jar.JarOutputStream jarOut  
    • Constructor Summary

      Constructors 
      Constructor Description
      JarWriter​(java.util.jar.JarOutputStream jarOut)  
      JarWriter​(java.util.jar.JarOutputStream jarOut, java.lang.String[] excludedExtensions)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.jar.JarOutputStream getJarOutputStream()
      Return the jar output stream being used by this JarWriter.
      static void main​(java.lang.String[] args)
      Simple test for the JarWriter
      boolean outputEntry​(java.lang.String path, long time, java.io.InputStream in, TaskMonitor monitor)
      Outputs an individual entry to the jar.
      boolean outputFile​(java.io.File baseFile, java.lang.String jarPath, TaskMonitor monitor)
      Outputs an individual file to the jar.
      boolean outputRecursively​(java.io.File baseFile, java.lang.String jarPath, TaskMonitor monitor)
      Recursively outputs a directory to the jar output stream If baseFile is a file then it is simply output to the jar.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • jarOut

        protected java.util.jar.JarOutputStream jarOut
    • Constructor Detail

      • JarWriter

        public JarWriter​(java.util.jar.JarOutputStream jarOut)
        Parameters:
        jarOut - the the jar file output stream the zip entries are to be written to.
      • JarWriter

        public JarWriter​(java.util.jar.JarOutputStream jarOut,
                         java.lang.String[] excludedExtensions)
    • Method Detail

      • outputFile

        public boolean outputFile​(java.io.File baseFile,
                                  java.lang.String jarPath,
                                  TaskMonitor monitor)
        Outputs an individual file to the jar.
        Parameters:
        baseFile - the file to be output
        jarPath - the base path to prepend to the file as it is written to the jar output stream.
        monitor - cancellable task monitor
        Returns:
        true if file is output to the jar file successfully.
      • outputEntry

        public boolean outputEntry​(java.lang.String path,
                                   long time,
                                   java.io.InputStream in,
                                   TaskMonitor monitor)
        Outputs an individual entry to the jar. The data input stream will be read until and EOF is read.
        Parameters:
        path - entry path within the jar file
        time - entry time
        in - data input stream
        monitor - cancellable task monitor
        Returns:
        true if entry is output to the jar file successfully.
      • outputRecursively

        public boolean outputRecursively​(java.io.File baseFile,
                                         java.lang.String jarPath,
                                         TaskMonitor monitor)
        Recursively outputs a directory to the jar output stream If baseFile is a file then it is simply output to the jar.
        Parameters:
        baseFile - the file or directory to be output
        jarPath - the base path to prepend to the files as they are written to the jar output stream.
        Returns:
        true if all files are recursively output to the jar file.
      • getJarOutputStream

        public java.util.jar.JarOutputStream getJarOutputStream()
        Return the jar output stream being used by this JarWriter.
      • main

        public static void main​(java.lang.String[] args)
        Simple test for the JarWriter
        Parameters:
        args - args[0] is the source directory, args[1] is the output filename