public final class ExternFileUtil
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
ExternFileUtil()
Prevent instances of this utility class.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
createAndWrite(java.lang.String path,
java.lang.String content)
Creates a new file which is referred to be the given path and writes the supplied content into it, by using
createEmpty(String) . |
static boolean |
createEmpty(java.lang.String path)
Creates a new empty file with the supplied path name, if the path doesn't refer to an existing file.
|
static boolean |
exists(java.lang.String path)
Checks whether the supplied file path exists or not.
|
static java.util.List<java.lang.String> |
getContentLines(java.lang.String path)
Returns the content of the supplied file as list of lines.
|
static boolean |
isAccessible(java.lang.String path)
Check whether the file is accessible for read operations or not.
|
static boolean |
isFile(java.lang.String path)
Checks whether the supplied path refers to a file or not.
|
static boolean |
isFile(java.lang.String path,
java.lang.String suffix)
Checks whether the supplied path refers to a file of a certain type or not.
|
static boolean |
remove(java.lang.String path)
Removes the file referred to by the supplied file path if it's existing.
|
static boolean |
write(java.lang.String path,
java.lang.String content)
Writes the given content to the file referred to by the supplied path name.
|
public static boolean exists(java.lang.String path)
path
- The path referred to the file which existence shall be checked.true
if the supplied path refers to an existing file, otherwise false
.public static boolean isAccessible(java.lang.String path)
path
- The path referred to the file of which the accessibility shall be checked.true
if the supplied path refers to an accessible file, otherwise
false
.public static boolean isFile(java.lang.String path)
path
- The path which shall be checked.true
if the supplied path refers to a file, otherwise false
.public static boolean isFile(java.lang.String path, java.lang.String suffix)
path
- The path which shall be checked.suffix
- The suffix of this file.true
if the supplied path refers to a file, otherwise false
.public static java.util.List<java.lang.String> getContentLines(java.lang.String path)
null
will be
returned instead.path
- The file which content shall be returned as list of lines.List
of lines as String
representing the supplied files content.public static boolean remove(java.lang.String path)
path
- The path pointing to the file which shall be removed.true
on success, otherwise false
.public static boolean createEmpty(java.lang.String path)
path
- The path to the new file.true
on success, otherwise false
.public static boolean write(java.lang.String path, java.lang.String content)
path
- The path to the file to which the supplied content shall be written.content
- The content which shall be written to the given file.true
on success, otherwise false
.public static boolean createAndWrite(java.lang.String path, java.lang.String content)
createEmpty(String)
.path
- The path the new file which shall be created.content
- The content which shall be written to the new file.true
, on success, otherwise false
.