Class FileUtils


  • public class FileUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean exists​(java.lang.String file)  
      static java.lang.String getFileURI​(java.lang.String fileName)
      Creates a URI from a given file name.
      static java.util.Collection<java.lang.String> getFileURIs​(java.lang.String... fileNameList)
      Creates a collection of URIs from a given list of files.
      static java.util.Collection<java.lang.String> getFileURIsFromRegex​(java.lang.String... fileNameRegexList)
      Creates a collection of URIs from a given regex list.
      static java.lang.String readAll​(java.io.Reader reader)  
      static java.lang.String readFile​(java.io.File file)  
      static java.lang.String readFile​(java.lang.String fileName)  
      static java.lang.String readURL​(java.net.URL fileURL)  
      static java.lang.String toURI​(java.lang.String fileName)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileUtils

        public FileUtils()
    • Method Detail

      • exists

        public static boolean exists​(java.lang.String file)
      • readURL

        public static java.lang.String readURL​(java.net.URL fileURL)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readFile

        public static java.lang.String readFile​(java.io.File file)
                                         throws java.io.FileNotFoundException,
                                                java.io.IOException
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • readFile

        public static java.lang.String readFile​(java.lang.String fileName)
                                         throws java.io.FileNotFoundException,
                                                java.io.IOException
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • readAll

        public static java.lang.String readAll​(java.io.Reader reader)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • toURI

        public static java.lang.String toURI​(java.lang.String fileName)
      • getFileURIsFromRegex

        public static java.util.Collection<java.lang.String> getFileURIsFromRegex​(java.lang.String... fileNameRegexList)

        Creates a collection of URIs from a given regex list. The given list can contain either absolute (local or remote) URIs or a Java regex expression for a local path. If a regex is given all the files whose name matches the regex will be added to the resulting list.

        The regular expressions supported by this function are Java regular expressions. If we want to get the URIS for all the files in a directory we need to pass /path/to/dir/.*

        Parameters:
        fileNameRegexList - list of regular expressions for fiel URIs
        Returns:
        list of file URIs matching the given regular expressions
      • getFileURIs

        public static java.util.Collection<java.lang.String> getFileURIs​(java.lang.String... fileNameList)
        Creates a collection of URIs from a given list of files.
        Parameters:
        fileNameList - the list of files
        Returns:
        a list of URIs
      • getFileURI

        public static java.lang.String getFileURI​(java.lang.String fileName)
        Creates a URI from a given file name.
        Parameters:
        fileName - the file
        Returns:
        a string representing the file URI