Class FileUtil


  • public final class FileUtil
    extends java.lang.Object
    Defines a file utility.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String extractURLPath​(java.net.URL url)
      Extract the path from an url
      static FileUtil getInstance()
      Get the instance
      java.lang.String readFileContent​(java.io.File file)
      Read the file content
      java.lang.String readFileContent​(java.io.File file, java.nio.charset.Charset charset)
      Read the file content
      java.lang.String readFileContent​(java.net.URL url)
      Read file content from a url
      java.lang.String readFileContent​(java.nio.file.Path file)
      Read the file content
      java.lang.String readFileContent​(java.nio.file.Path file, java.nio.charset.Charset charset)
      Read the file content
      java.lang.String slashify​(java.lang.String path)
      Slashify the path
      • Methods inherited from class java.lang.Object

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

      • getInstance

        public static FileUtil getInstance()
        Get the instance
        Returns:
        the instance
      • slashify

        public java.lang.String slashify​(java.lang.String path)
        Slashify the path
        Parameters:
        path - the path
        Returns:
        the prepared path
      • extractURLPath

        public java.lang.String extractURLPath​(java.net.URL url)
        Extract the path from an url
        Parameters:
        url - the url
        Returns:
        the path
      • readFileContent

        public java.lang.String readFileContent​(java.io.File file)
                                         throws java.io.IOException
        Read the file content
        Parameters:
        file - the file
        Returns:
        the content
        Throws:
        java.io.IOException - In case of an IO error
      • readFileContent

        public java.lang.String readFileContent​(java.nio.file.Path file)
                                         throws java.io.IOException
        Read the file content
        Parameters:
        file - the file
        Returns:
        the content
        Throws:
        java.io.IOException - In case of an IO error
      • readFileContent

        public java.lang.String readFileContent​(java.io.File file,
                                                java.nio.charset.Charset charset)
                                         throws java.io.IOException
        Read the file content
        Parameters:
        file - the file
        charset - the charset
        Returns:
        the content
        Throws:
        java.io.IOException - In case of an IO error
      • readFileContent

        public java.lang.String readFileContent​(java.nio.file.Path file,
                                                java.nio.charset.Charset charset)
                                         throws java.io.IOException
        Read the file content
        Parameters:
        file - the file
        charset - the charset
        Returns:
        the content
        Throws:
        java.io.IOException - In case of an IO error
      • readFileContent

        public java.lang.String readFileContent​(java.net.URL url)
                                         throws java.io.IOException
        Read file content from a url
        Parameters:
        url - the url
        Returns:
        the content
        Throws:
        java.io.IOException - In case of an IO error