public class FileUtil extends Object
Constructor and Description |
---|
FileUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
changeExtension(String originalName,
String newExtension)
Change or add the given filename extension. if file extension is the same
(case is ignored), no change are made.
|
static String |
changeFileNameToClassName(String filePath)
Change the passed file name to its corresponding class name.The file path
has to be limited to the package part (i.e. no "C:" for instance)
|
static Set<Class<?>> |
findClassesInPackage(Package pack,
Class<?> superClass,
boolean isInterface)
Get all the classes (or interfaces) in a package (and its subpackages)
that
have superClass has a super class.
|
static List<String> |
getAllFileNamesInDir(File dir)
Visits all files and directories in a given directory and gets the name
of
all files found.
|
static List<String> |
getAllFileNamesInDir(File dir,
boolean extension,
String extensionFilter)
Visits all files and directories in a given directory and gets the name
of
all files found.
|
static List<File> |
getAllFilesInDir(File dir)
Visits all files and directories in a given directory and gets all files
found.
|
static List<File> |
getAllFilesInDir(File dir,
Collection<String> exceptColn)
Visits all files and directories in a given directory and gets all files
found, except the ones in the directories named in exceptColn.
|
static File |
getNamedFileInDir(File directory,
String filename)
Get a file inside a given directory from its name.
|
static String |
getResourceFolderPath(String resource)
Get the path of the folder of a given CartAGen resource (e.g.
|
public static List<File> getAllFilesInDir(File dir)
dir
- public static List<File> getAllFilesInDir(File dir, Collection<String> exceptColn)
dir
- public static List<String> getAllFileNamesInDir(File dir)
dir
- public static List<String> getAllFileNamesInDir(File dir, boolean extension, String extensionFilter)
dir
- the directory in which files are searched recursively.extension
- true if you the file extension to be included in the file
name, e.g. "road.shp".extensionFilter
- e.g. ".shp" to get only shapefiles, put null to
avoid filtering.public static String changeFileNameToClassName(String filePath)
filePath
- Class name to be changed. If this does not represent a Java
class then null is returned.IllegalArgumentException
- If a null name passed.public static String getResourceFolderPath(String resource)
resource
- public static File getNamedFileInDir(File directory, String filename)
directory
- the directory to search infilename
- public static Set<Class<?>> findClassesInPackage(Package pack, Class<?> superClass, boolean isInterface)
pack
- superClass
- isInterface
- public static String changeExtension(String originalName, String newExtension)
originalName
- filename with extension to be changednewExtension
- extension begining with "." or not ("." is added if not)Copyright © 2016 Laboratoire COGIT, IGN. All rights reserved.