public class FileUtil extends Object
| Constructor and Description | 
|---|
| FileUtil() | 
| Modifier and Type | Method and Description | 
|---|---|
| static void | copyFile(File source,
        File destination)Copies the contents of file source to file destination. | 
| static void | createDirIfNotExists(File dir)Creates a directory if it doesn't exist yet. | 
| static File | createTempDir(String prefix)Deprecated. 
 | 
| static boolean | deleteChildren(File directory)Deletes all files and subdirectories in the specified directory. | 
| static void | deleteDir(File dir)Deletes the specified directory and any files and directories in it recursively. | 
| static boolean | deleteFiles(File directory)Deletes all files in the specified directory. | 
| static boolean | deltree(File directory)Deletes a directory, recursively deleting all the files and subdirectories in it, or just a file. | 
| static String | getFileExtension(String fileName)Gets the extension of the specified file name. | 
| static File | getRelativeFile(File subj,
               File relativeTo)Gets the relative representations of a file compared to another. | 
| static String | getRelativePath(File subj,
               File relativeTo)Gets the relative representations of a file compared to another. | 
| static boolean | isLegalFileName(String fileName)Checks whether the specified file name is a legal (DOS/Windows-) file name. | 
| static boolean | isLegalFileNameChar(char c)Checks whether the specified character is a legal (DOS/Windows-) file name character. | 
| static boolean | moveRecursive(File from,
             File to,
             Collection<File> excludes)Moves the given file and all files under it (if it's a directory) to the given location, excluding the given
 collection of File objects! | 
public static String getRelativePath(File subj, File relativeTo)
subj - The File to find the relative form for.relativeTo - The File 'subj' should be made relative to.public static File getRelativeFile(File subj, File relativeTo)
subj - The File to find the relative form for.relativeTo - The File 'subj' should be made relative to.public static String getFileExtension(String fileName)
fileName - A file name.public static boolean isLegalFileName(String fileName)
fileName - name of the filepublic static boolean isLegalFileNameChar(char c)
c - character to checkpublic static void copyFile(File source, File destination) throws IOException
source - source filedestination - destination fileIOExceptionpublic static void createDirIfNotExists(File dir) throws IOException
dir - The directory to create.IOException - If the creation of the directory failed.public static boolean deltree(File directory)
directory - file or directory to deletepublic static boolean deleteFiles(File directory)
directory - public static boolean deleteChildren(File directory)
directory - public static boolean moveRecursive(File from, File to, Collection<File> excludes)
from - File or directory to be movedto - The file or directory to rename toexcludes - The File objects to be excluded; if a directory is excluded, all files under it are excluded as
                 well!@Deprecated public static File createTempDir(String prefix) throws IOException
Files.createTempDirectory(String, java.nio.file.attribute.FileAttribute...) insteadprefix - The prefix string to be used in generating the directory's name; must be at least three characters
               long.IOException - If no directory could be created.public static void deleteDir(File dir) throws IOException
dir - The directory to remove.IOException - If the directory could not be removed.Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.