Class Files


  • public final class Files
    extends java.lang.Object
    Utility class for file operations
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void deleteRecursively​(java.io.File dir)
      Recursively delete a directory.
      static java.io.File toFile​(java.net.URI uri)
      Convert a URI to a file but handle a corner case with UNC paths which do not parse correctly.
      static java.io.File toFile​(java.net.URL url)
      Convert a URL to a file but handle a corner case with UNC paths which do not parse correctly.
      • Methods inherited from class java.lang.Object

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

      • toFile

        public static java.io.File toFile​(java.net.URL url)
                                   throws java.net.URISyntaxException
        Convert a URL to a file but handle a corner case with UNC paths which do not parse correctly.
        Parameters:
        url - URL to convert
        Returns:
        File
        Throws:
        java.net.URISyntaxException - if the URL cannot be converted to a URI
      • toFile

        public static java.io.File toFile​(java.net.URI uri)
        Convert a URI to a file but handle a corner case with UNC paths which do not parse correctly.
        Parameters:
        uri - URI to convert
        Returns:
        File
      • deleteRecursively

        public static void deleteRecursively​(java.io.File dir)
                                      throws java.io.IOException
        Recursively delete a directory. Does not support symlinks but this is mainly used by mixin internals which only write files and normal directories so it should be fine
        Parameters:
        dir - Root directory to delete
        Throws:
        java.io.IOException - Security errors and any other IO errors encountered are raised as IOExceptions