Class Dir

java.lang.Object
com.github.oeuvres.alix.util.Dir

public class Dir extends Object
Static tools to deal with directories (and files). Kept in java 7.
  • Method Details

    • globNorm

      public static String globNorm(String glob, File base) throws IOException
      Resolve relative links for glob.
      Parameters:
      glob - requested path as a glob.
      base - file from which resolve relative links.
      Returns:
      an absolute glob.
      Throws:
      IOException - file exceptions.
    • include

      public static List<Path> include(List<Path> paths, String glob) throws IOException
      Add files to a list with a glob.
      Parameters:
      paths - list of paths to populate.
      glob - pattern of file to append.
      Returns:
      the list of paths completed.
      Throws:
      IOException - file errors.
    • exclude

      public static List<Path> exclude(List<Path> paths, String glob) throws IOException
      Delete files from a list by glob.
      Parameters:
      paths - list of files.
      glob - pattern to select files.
      Returns:
      list of selected paths.
      Throws:
      IOException - file errors.
    • ls

      public static List<Path> ls(String glob) throws IOException
      List files by glob.
      Parameters:
      glob - pattern to select files.
      Returns:
      list of selected paths.
      Throws:
      IOException - file errors.
    • rm

      public static boolean rm(Path path) throws IOException
      Delete a folder by path (use java.nio stream, should be faster then rm(File))
      Parameters:
      path - file to delete.
      Returns:
      true if exists and deleted, false otherwise.
      Throws:
      IOException - file error.
    • rm

      public static boolean rm(File file)
      Delete a folder by File object (maybe a bit slow for lots of big folders).
      Parameters:
      file - folder to delete.
      Returns:
      true if exists and deleted, false otherwise.