Class FileHelper


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.File createNonexistentTempFile​(java.io.File parent, java.lang.String prefix, java.lang.String suffix)  
      static java.io.File createNonexistentTempFile​(java.lang.String prefix, java.lang.String suffix)
      Creates a temporary file that is guaranteed not to exist on file system.
      static java.lang.String extension​(java.io.File f)  
      static java.lang.String extension​(java.lang.String filename)  
      static void forceDelete​(java.io.File file)
      Recursively deletes a directory or a file.
      static void forceMkdir​(java.io.File directory)
      Creates a directory.
      static java.lang.String removeExtension​(java.io.File f)
      Returns file name without extension part.
      static java.lang.String toUnixSeparatedString​(java.nio.file.Path path)
      Returns a string representation of path with unix separators ("/") instead of the system-dependent separators (which is backslash on Windows).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • extension

        public static java.lang.String extension​(java.io.File f)
      • extension

        public static java.lang.String extension​(java.lang.String filename)
      • removeExtension

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

        public static java.io.File createNonexistentTempFile​(java.lang.String prefix,
                                                             java.lang.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 java.io.File createNonexistentTempFile​(java.io.File parent,
                                                             java.lang.String prefix,
                                                             java.lang.String suffix)
      • forceMkdir

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

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

        public static java.lang.String toUnixSeparatedString​(java.nio.file.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:
        java.lang.IllegalArgumentException - if path is null