Package com.github.toolarium.common.util
Class FileUtil
java.lang.Object
com.github.toolarium.common.util.FileUtil
Defines a file utility.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionextractURLPath(URL url) Extract the path from an urlstatic FileUtilGet the instancebooleanisReadable(String fileName) Checks whether the given file is readable.booleanisWritable(String fileName) Checks whether the given file is writable.readFileContent(File file) Read the file contentreadFileContent(File file, Charset charset) Read the file contentreadFileContent(URL url) Read file content from a urlreadFileContent(Path file) Read the file contentreadFileContent(Path file, Charset charset) Read the file contentSlashify the path
-
Field Details
-
SLASH
public static final char SLASH- See Also:
-
BACKSLASH
public static final char BACKSLASH- See Also:
-
SLASH_STR
- See Also:
-
BACKSLASH_STR
- See Also:
-
-
Method Details
-
getInstance
Get the instance- Returns:
- the instance
-
slashify
Slashify the path- Parameters:
path- the path- Returns:
- the prepared path
-
isReadable
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
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
Extract the path from an url- Parameters:
url- the url- Returns:
- the path
-
readFileContent
Read the file content- Parameters:
file- the file- Returns:
- the content
- Throws:
IOException- In case of an IO error
-
readFileContent
Read the file content- Parameters:
file- the file- Returns:
- the content
- Throws:
IOException- In case of an IO error
-
readFileContent
Read the file content- Parameters:
file- the filecharset- the charset- Returns:
- the content
- Throws:
IOException- In case of an IO error
-
readFileContent
Read the file content- Parameters:
file- the filecharset- the charset- Returns:
- the content
- Throws:
IOException- In case of an IO error
-
readFileContent
Read file content from a url- Parameters:
url- the url- Returns:
- the content
- Throws:
IOException- In case of an IO error
-