Package com.github.toolarium.common.util
Class FileUtil
- java.lang.Object
-
- com.github.toolarium.common.util.FileUtil
-
public final class FileUtil extends java.lang.ObjectDefines a file utility.
-
-
Field Summary
Fields Modifier and Type Field Description static charBACKSLASHstatic java.lang.StringBACKSLASH_STRstatic charSLASHstatic java.lang.StringSLASH_STR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringextractURLPath(java.net.URL url)Extract the path from an urlstatic FileUtilgetInstance()Get the instancejava.lang.StringreadFileContent(java.io.File file)Read the file contentjava.lang.StringreadFileContent(java.io.File file, java.nio.charset.Charset charset)Read the file contentjava.lang.StringreadFileContent(java.net.URL url)Read file content from a urljava.lang.StringreadFileContent(java.nio.file.Path file)Read the file contentjava.lang.StringreadFileContent(java.nio.file.Path file, java.nio.charset.Charset charset)Read the file contentjava.lang.Stringslashify(java.lang.String path)Slashify the path
-
-
-
Field Detail
-
SLASH
public static final char SLASH
- See Also:
- Constant Field Values
-
BACKSLASH
public static final char BACKSLASH
- See Also:
- Constant Field Values
-
SLASH_STR
public static final java.lang.String SLASH_STR
- See Also:
- Constant Field Values
-
BACKSLASH_STR
public static final java.lang.String BACKSLASH_STR
- See Also:
- Constant Field Values
-
-
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.IOExceptionRead 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.IOExceptionRead 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.IOExceptionRead the file content- Parameters:
file- the filecharset- 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.IOExceptionRead the file content- Parameters:
file- the filecharset- 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.IOExceptionRead file content from a url- Parameters:
url- the url- Returns:
- the content
- Throws:
java.io.IOException- In case of an IO error
-
-