Package PamUtils

Class FileParts

java.lang.Object
PamUtils.FileParts

public class FileParts extends Object
Class for breaking a file name down into it's constituent parts.
Author:
Doug Gillespie
  • Constructor Details

    • FileParts

      public FileParts()
    • FileParts

      public FileParts(File file)
    • FileParts

      public FileParts(String absPath)
  • Method Details

    • setFileName

      public void setFileName(String absPath)
    • getFileName

      public String getFileName()
    • getFolderName

      public String getFolderName()
    • getFileEnd

      public String getFileEnd()
    • getFileNameAndEnd

      public String getFileNameAndEnd()
    • getFolderParts

      public String[] getFolderParts()
    • getLastFolderPart

      public String getLastFolderPart()
    • getFileSeparator

      public static String getFileSeparator()
    • getFolderPartsBetween

      public static String[] getFolderPartsBetween(File aFileOrDir, File aHigherDirectory)
      Parameters:
      aFileOrDir -
      aHigherDirectory -
      Returns:
      Directories between file/dir in question and the higher directory specified. Returns null if not in the higher directory at all. NB Uses isWithin!

      Add another String to the array with the file/dir name to give a "relative file"

    • isWithin

      public static Integer isWithin(File aFileOrDir, File aHigherDirectory)
      Parameters:
      aFileOrDir -
      aHigherDirectory -
      Returns:
      depth of subfolders of file/dir in higher directory NB: Based on Abstract Paths. If referring to same file through different route, will return false. Eg. with a net drive mapped as both N and M; isWithin(new File("M:\\foo\\bar.txt"),new File("N:\\foo")) will return false!
    • isWithin

      public static boolean isWithin(File aDir, File deeperFileOrDir, boolean c)
      Parameters:
      aDir -
      deeperFileOrDir -
      c - unused but to make it different from other method!
      Returns:
      true if aDir contains deeperFileDir