com.b3dgs.lionengine.utility
Class Files

java.lang.Object
  extended by com.b3dgs.lionengine.utility.Files

public final class Files
extends java.lang.Object

Static functions giving informations related to files and dir.


Method Summary
static void deleteDir(java.io.File dir)
          Delete a directory and all of its content (be careful, it will erase all children, including child dirs).
static boolean exists(java.lang.String path)
          Check if the path exists.
static java.lang.String[] getDirsList(java.lang.String path)
          Get all directorys existing in the path.
static java.lang.String getExtension(java.io.File file)
          Get a file extension.
static java.lang.String getExtension(java.lang.String file)
          Get extension from a string (search first dot).
static java.lang.String getFilenameFromPath(java.lang.String path)
          Get the filename from a path (last part of a path, after the last separator).
static java.lang.String[] getFilesList(java.lang.String path)
          Get all files existing in the path.
static java.lang.String[] getFilesList(java.lang.String path, java.lang.String ext)
          Get all files existing in the path.
static java.lang.String getLocalPath(java.lang.String... path)
          Construct a usable path using a list of string, automatically separated by the portable separator.
static java.lang.String getRelativePath(java.lang.String... path)
          Construct a usable path using a list of string, automatically separated by the portable separator.
static boolean isDir(java.lang.String path)
          Check if the path is a directory.
static boolean isFile(java.lang.String path)
          Check if the path is a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isDir

public static boolean isDir(java.lang.String path)
Check if the path is a directory.

Parameters:
path - path to check.
Returns:
is a directory ?

isFile

public static boolean isFile(java.lang.String path)
Check if the path is a file.

Parameters:
path - path to check.
Returns:
true if it is a file.

exists

public static boolean exists(java.lang.String path)
Check if the path exists.

Parameters:
path - path to check.
Returns:
true if exists.

getExtension

public static java.lang.String getExtension(java.io.File file)
Get a file extension.

Parameters:
file - file.
Returns:
extension.

getExtension

public static java.lang.String getExtension(java.lang.String file)
Get extension from a string (search first dot).

Parameters:
file - filename.
Returns:
extension.

getDirsList

public static java.lang.String[] getDirsList(java.lang.String path)
Get all directorys existing in the path.

Parameters:
path - path to check.
Returns:
directorys list.

getFilesList

public static java.lang.String[] getFilesList(java.lang.String path)
Get all files existing in the path.

Parameters:
path - path to check.
Returns:
files list.

getFilesList

public static java.lang.String[] getFilesList(java.lang.String path,
                                              java.lang.String ext)
Get all files existing in the path.

Parameters:
path - path to check.
ext - extension (without dot; ex: png).
Returns:
files list.

deleteDir

public static void deleteDir(java.io.File dir)
Delete a directory and all of its content (be careful, it will erase all children, including child dirs).

Parameters:
dir - directory to delete with all of its content.

getFilenameFromPath

public static java.lang.String getFilenameFromPath(java.lang.String path)
Get the filename from a path (last part of a path, after the last separator).

Parameters:
path - path used to extract filename.
Returns:
filename extracted from path.

getLocalPath

public static java.lang.String getLocalPath(java.lang.String... path)
Construct a usable path using a list of string, automatically separated by the portable separator. The constructed path will use local system file separator.

Parameters:
path - list of strings.
Returns:
usable path.

getRelativePath

public static java.lang.String getRelativePath(java.lang.String... path)
Construct a usable path using a list of string, automatically separated by the portable separator. The constructed path will use a separator depending of local mode (applet or standard). In case of applet, the separator used is the same as for the internet.

Parameters:
path - list of strings.
Returns:
usable path.