Class FileLister

  • All Implemented Interfaces:
    java.lang.Iterable<FileLister.Entry>

    public class FileLister
    extends java.lang.Object
    implements java.lang.Iterable<FileLister.Entry>
    Utility class to present a uniform iterator interface for file containers; presently includes directories and jar files.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FileLister.Entry  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.ref.WeakReference<FileContainer> containerRef
      weak ref to a container to avoid hanging on to an open jar file.
      (package private) java.lang.String name  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileLister​(java.lang.String dirOrJarName)  
    • Field Detail

      • containerRef

        volatile java.lang.ref.WeakReference<FileContainer> containerRef
        weak ref to a container to avoid hanging on to an open jar file.
      • name

        java.lang.String name
    • Constructor Detail

      • FileLister

        public FileLister​(java.lang.String dirOrJarName)
                   throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • open

        public FileLister.Entry open​(java.lang.String relativeFileName)
                              throws java.io.IOException
        Parameters:
        relativeFileName -
        Returns:
        if the relativeFileName exists in the directory or jar represented by FileLister object open it. If not return null.
        Throws:
        java.io.IOException
      • getContainer

        private FileContainer getContainer()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • openJar

        private FileContainer openJar​(java.lang.String jarFile)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • check

        public static boolean check​(java.lang.String src,
                                    java.lang.String dst)
        check if dst is up to date with src, ie at least as new
        Parameters:
        src - the source filename
        dst - the destination filename
        Returns:
        true if dst exists and is at least as new as src