Class FileUtils


  • public final class FileUtils
    extends Object
    Helper methods to deal with files.
    Version:
    $Rev$
    Author:
    herrmama, $Author$
    • Method Detail

      • getContents

        public static String getContents​(org.eclipse.core.resources.IFile file)
        Get contents of an Eclipse resource file as string.
      • resolveFile

        public static org.eclipse.core.resources.IFile resolveFile​(org.eclipse.core.resources.IContainer container,
                                                                   String name)
        Resolve a file name with respect to a container which may be a project or a folder.
      • move

        public static void move​(File source,
                                File target)
        Move a file.
      • move

        public static void move​(org.eclipse.emf.common.util.URI source,
                                org.eclipse.emf.common.util.URI target)
        Move a file.
      • delete

        public static void delete​(File target)
        Delete a file.
      • delete

        public static void delete​(org.eclipse.emf.common.util.URI target)
        Delete a file.
      • copy

        public static void copy​(org.eclipse.emf.common.util.URI source,
                                org.eclipse.emf.common.util.URI target)
                         throws IOException
        Copy a file.
        Throws:
        IOException
      • createDir

        public static void createDir​(String name)
        Create a directory.
      • getExtension

        public static String getExtension​(File file)
        Get the extension of a file. Returns null if there is not extension.
      • getNameWithoutExtension

        public static String getNameWithoutExtension​(File file)
        Get the name of a file without its extension.
      • replaceFileExtension

        public static File replaceFileExtension​(File file,
                                                String newExtension)
        Replace the extension of a file with another one.
      • deleteContents

        public static void deleteContents​(File dir)
        Delete the contents of a directory (without deleting the directory itself).
      • getFile

        public static org.eclipse.core.resources.IFile getFile​(String fullPath)
        Get a file from the workspace. The path must be workspace-relative. This method always returns a file. However, this does not necessarily exist.