public final class Manager
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
Manager() |
Modifier and Type | Method and Description |
---|---|
static int |
countLines(java.lang.String filename)
Counts the number of lines in a text file
|
static boolean |
dirExists(java.lang.String path)
Checks for the existence of a directory.
|
static boolean |
fileExists(java.lang.String path)
Checks for the existence of a file
|
static java.lang.StringBuilder |
fileToString(java.io.File file)
Convert text file to String, without throwing exceptions.
|
static java.io.File |
getAlternativeFileName(java.io.File file) |
static java.lang.String |
getCurrentWorkingDir() |
static java.util.Set<java.io.File> |
getSubDirs(java.io.File dir)
Retrieves the subdirectories of a directory
|
static boolean |
isDirEmpty(java.nio.file.Path directory) |
static boolean |
isImageFile(java.lang.String fileName)
Determines if a file is an .jpg, .png or .img image file
|
static boolean |
makeNewFile(java.lang.String path)
Creates a new file, given a path
If did not existed, creates it alongside the parent directory
If existed previously, overwrites it
|
static java.lang.String |
makeTildeIntoHomeDir(java.lang.String path) |
private static java.lang.StringBuilder |
readFile(java.io.File file)
Build a String from the contents of a file
|
static java.io.File |
stringToFile(java.lang.String path,
java.lang.String content) |
private static java.lang.StringBuilder readFile(java.io.File file) throws java.io.IOException
file
- Text file to be readjava.io.IOException
- In case of error reading the file.public static java.lang.StringBuilder fileToString(java.io.File file)
file
- File to be readpublic static boolean dirExists(java.lang.String path)
path
- Path of the directorypublic static boolean fileExists(java.lang.String path)
path
- Path to the filepublic static boolean makeNewFile(java.lang.String path) throws java.io.IOException
path
- Absolute path to the filejava.io.IOException
- If it could not create the file.public static java.util.Set<java.io.File> getSubDirs(java.io.File dir)
dir
- The directory to be searchedpublic static boolean isImageFile(java.lang.String fileName)
fileName
- the full path to the filepublic static int countLines(java.lang.String filename) throws java.io.IOException
filename
- The full path to the filejava.io.IOException
- When failed to count the number of linespublic static java.io.File stringToFile(java.lang.String path, java.lang.String content)
public static java.io.File getAlternativeFileName(java.io.File file)
public static boolean isDirEmpty(java.nio.file.Path directory) throws java.io.IOException
java.io.IOException
public static java.lang.String makeTildeIntoHomeDir(java.lang.String path)
public static java.lang.String getCurrentWorkingDir()