Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
create(File f)
Creates a file if it doesn't already exist using
File.createNewFile() . |
static File |
createTempFile(String name)
Create a temporary file with the specified name.
|
static boolean |
delete(File f)
Recursively deletes a file or directory.
|
static String |
getBaseName(String name)
Strips the extension from a file name.
|
static String |
getExtension(String name)
Returns the extension from a file name.
|
static File |
mkdirs(File f,
boolean clean)
Same as
File.mkdirs() except throws a RuntimeExeption if directory could not be created. |
static File |
mkdirs(String path,
boolean clean)
Same as
mkdirs(String, boolean) but uses String path. |
static void |
modifyTimestamp(File f)
Updates the modified timestamp on the specified file.
|
public FileUtils()
public static File mkdirs(File f, boolean clean)
File.mkdirs()
except throws a RuntimeExeption if directory could not be created.f
- The directory to create. Must not be clean
- If RuntimeException
- if directory could not be created.public static File mkdirs(String path, boolean clean)
mkdirs(String, boolean)
but uses String path.path
- The path of the directory to create. Must not be clean
- If public static boolean delete(File f)
f
- The file or directory to delete.public static void create(File f)
File.createNewFile()
.
Throws a RuntimeException
if the file could not be created.
f
- The file to create.public static void modifyTimestamp(File f)
Method ensures that the timestamp changes even if it's been modified within the past millisecond.
f
- The file to modify the modified timestamp on.public static File createTempFile(String name) throws IOException
The name is broken into file name and suffix, and the parts are passed to
File.createTempFile(String, String)
.
File.deleteOnExit()
is called on the resulting file before being returned by this method.
name
- The file nameIOException
public static String getBaseName(String name)
name
- The file name.public static String getExtension(String name)
name
- The file name.Copyright © 2018 Apache. All rights reserved.