public class FileUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FILESEPARATOR
platform independent file path separator like "\" on windows or "/" on unix
|
static java.lang.String |
LINESEPARATOR
platform independent line separator (line feed/line break) for files/strings
|
static java.lang.String |
USERHOMEDIR
platform independent home directory of the current user (notice: the path ends with a file separator)
|
Modifier and Type | Method and Description |
---|---|
static java.io.File |
createFilePath(java.lang.String filename)
Creates the file and corresponding directories if it/they don't exist.
|
static java.lang.String |
getDirFromFilePath(java.lang.String filename)
Gets the path to the last directory of the given filename.
|
static boolean |
hasExtension(java.io.File file)
Indicates if the given file has a valid file extension.
|
static boolean |
hasExtension(java.lang.String filename)
Indicates if the given file name has a valid file extension.
|
static java.io.File |
validateFile(java.io.File file,
java.lang.String extension)
Validates a file meaning that the file is checked for a valid extension and if this is not the case then the
file is expanded by the extension that is specified.
|
public static final java.lang.String FILESEPARATOR
public static final java.lang.String USERHOMEDIR
public static final java.lang.String LINESEPARATOR
public static java.io.File createFilePath(java.lang.String filename) throws java.io.IOException
filename
- the name and path of the fileFile
java.io.IOException
- public static java.lang.String getDirFromFilePath(java.lang.String filename) throws java.lang.IllegalArgumentException
filename
- the name and path of the filejava.lang.IllegalArgumentException
- public static boolean hasExtension(java.io.File file) throws java.lang.IllegalArgumentException
file
- the filetrue
if the file has an extension otherwise false
java.lang.IllegalArgumentException
- public static boolean hasExtension(java.lang.String filename) throws java.lang.IllegalArgumentException
filename
- the name and path of the filetrue
if the file name has an extension otherwise false
java.lang.IllegalArgumentException
- public static java.io.File validateFile(java.io.File file, java.lang.String extension) throws java.lang.IllegalArgumentException
file
- the fileextension
- the extensionjava.lang.IllegalArgumentException
-