Class FileHelper

java.lang.Object
io.github.erdos.stencil.impl.FileHelper

public final class FileHelper extends Object
File handling utilities. Some methods may be called from Clojure core.
  • Method Details

    • extension

      public static String extension(File f)
    • extension

      public static String extension(String filename)
    • removeExtension

      public static String removeExtension(File f)
      Returns file name without extension part.
      Returns:
      simple file name without extension.
      Throws:
      NullPointerException - the input is null
    • createNonexistentTempFile

      public static File createNonexistentTempFile(String prefix, String suffix)
      Creates a temporary file that is guaranteed not to exist on file system.
      Parameters:
      prefix - file name starts with this file
      suffix - file name ends with this file
      Returns:
      a new file object pointing to a non-existing file in temp directory.
    • createNonexistentTempFile

      public static File createNonexistentTempFile(File parent, String prefix, String suffix)
    • forceMkdir

      public static void forceMkdir(File directory) throws IOException
      Creates a directory. Recursively creates parent directories too.
      Parameters:
      directory - not null dir to create
      Throws:
      IOException - on IO error
      IllegalArgumentException - when input is null or already exists
    • forceDelete

      public static void forceDelete(File file)
      Recursively deletes a directory or a file.
      Parameters:
      file - to delete, not null
      Throws:
      NullPointerException - on null or invalid file
    • toUnixSeparatedString

      public static String toUnixSeparatedString(Path path)
      Returns a string representation of path with unix separators ("/") instead of the system-dependent separators (which is backslash on Windows).
      Parameters:
      path - not null path object
      Returns:
      string of path with slash separators
      Throws:
      IllegalArgumentException - if path is null