public final class UtilFile extends Object
This class is Thread-Safe.
Modifier and Type | Method and Description |
---|---|
static void |
deleteFile(File file)
Delete a file.
|
static boolean |
exists(String path)
Check if the path exists.
|
static String |
getExtension(File file)
Get a file extension.
|
static String |
getExtension(String file)
Get extension from a string (search first dot).
|
static List<File> |
getFiles(File directory)
Get the files list from directory.
|
static List<File> |
getFilesByExtension(File path,
String extension)
Get all files existing in the path considering the extension.
|
static List<File> |
getFilesByName(File path,
String name)
Get all files existing in the path with the specified name.
|
static boolean |
isFile(String path)
Check if the path is a file.
|
static boolean |
isType(File file,
String extension)
Check if the following type is the expected type.
|
static String |
normalizeExtension(String file,
String extension)
Normalize the file extension by ensuring it has the required one.
|
static String |
removeExtension(String file)
Get the file name without its extension.
|
public static String removeExtension(String file)
Using "image.png"
as argument returns "image"
.
file
- The file name.LionEngineException
- If null
argument.public static String normalizeExtension(String file, String extension)
file
- The original file name.extension
- The desired extension (will replace the other one if has).LionEngineException
- If null
arguments.public static String getExtension(String file)
file
- The filename.LionEngineException
- If null
argument.public static String getExtension(File file)
file
- The file.LionEngineException
- If null
argument.public static List<File> getFiles(File directory)
directory
- The directory reference.LionEngineException
- If not a directory.public static List<File> getFilesByExtension(File path, String extension)
path
- The path to check.extension
- The extension (without dot; eg: png).public static List<File> getFilesByName(File path, String name)
path
- The path to check.name
- The file name.public static void deleteFile(File file)
file
- The file to delete.LionEngineException
- If unable to remove file.public static boolean exists(String path)
path
- The path to check.true
if exists, false
else.public static boolean isFile(String path)
path
- The path to check.true
if it is a file, false
else.Copyright © 2017 Byron 3D Games Studio. All rights reserved.