Class FileUtil

java.lang.Object
com.github.toolarium.common.util.FileUtil

public final class FileUtil extends Object
Defines a file utility.
  • Field Details

  • Method Details

    • getInstance

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

      public String slashify(String path)
      Slashify the path
      Parameters:
      path - the path
      Returns:
      the prepared path
    • isReadable

      public boolean isReadable(String fileName)
      Checks whether the given file is readable.
      Parameters:
      fileName - the filename to be checked
      Returns:
      true if the file can be read otherwise false
    • isWritable

      public boolean isWritable(String fileName)
      Checks whether the given file is writable.
      Parameters:
      fileName - the filename to be checked
      Returns:
      true if the file can be written otherwise false
    • extractURLPath

      public String extractURLPath(URL url)
      Extract the path from an url
      Parameters:
      url - the url
      Returns:
      the path
    • readFileContent

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

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

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

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

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