Class FileUtil


  • public class FileUtil
    extends Object
    • Constructor Detail

      • FileUtil

        public FileUtil()
    • Method Detail

      • getRelativeFile

        public static File getRelativeFile​(File workingDirectory,
                                           File targetFile)
        Returns a relative path for the targetFile relative to the base directory.
        Parameters:
        canonicalBase - base directory as returned by File.getCanonicalPath()
        targetFile - target file
        Returns:
        relative path of target file. Returns targetFile if there were no commonalities between the base and the target
      • breakPaths

        public static File[] breakPaths​(String paths)
      • truncatePath

        public static String truncatePath​(String path,
                                          String baseDirectory)
        Parameters:
        path - String
        baseDirectory - String
        Returns:
        relative path to a base directory if possible