Class FileUtilsExtra

java.lang.Object
org.aksw.commons.txn.impl.FileUtilsExtra

public class FileUtilsExtra extends Object
Eventually these file utils should be consolidated with those in aksw-commons-io. However, my feel is that first there should be a little framework that allows for modeling actions that have multiple prerequisites such as the existence of certain folders. These utils here only allow for a single prerequisite.
  • Constructor Details

    • FileUtilsExtra

      public FileUtilsExtra()
  • Method Details

    • streamFilenames

      public static Stream<Path> streamFilenames(Path folder) throws IOException
      Throws:
      IOException
    • ensureParentFolderExists

      public static <T> T ensureParentFolderExists(Path childPath, ThrowingRunnable action) throws IOException
      Throws:
      IOException
    • ensureParentFolderExists

      public static <T> T ensureParentFolderExists(Path childPath, Callable<T> action) throws IOException
      Throws:
      IOException
    • ensureFolderExists

      public static <T> T ensureFolderExists(Path folderPath, ThrowingRunnable action) throws IOException
      Throws:
      IOException
    • ensureFolderExists

      public static <T> T ensureFolderExists(Path folderPath, Callable<T> action) throws IOException
      Repeatedly retry to create the given file's parent folder and then perform an action based on that folder. Uses 10 retries with 100ms delay before failing. Useful if another process concurrently perform a 'deleteEmptyFolders' action an the same folder
      Parameters:
      action -
      path -
      Throws:
      IOException