Class FileUtils
- java.lang.Object
-
- org.eclipse.emf.edapt.internal.common.FileUtils
-
public final class FileUtils extends Object
Helper methods to deal with files.- Version:
- $Rev$
- Author:
- herrmama, $Author$
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copy(File source, File target)
Copy a file.static void
copy(org.eclipse.emf.common.util.URI source, org.eclipse.emf.common.util.URI target)
Copy a file.static void
createDir(String name)
Create a directory.static void
createFile(String name, String contents)
Create a file.static void
delete(File target)
Delete a file.static void
delete(org.eclipse.emf.common.util.URI target)
Delete a file.static void
deleteContents(File dir)
Delete the contents of a directory (without deleting the directory itself).static String
getContents(File file)
Get contents of a Java file as string.static String
getContents(InputStream in)
Read contents of an input stream to a string.static String
getContents(org.eclipse.core.resources.IFile file)
Get contents of an Eclipse resource file as string.static String
getExtension(File file)
Get the extension of a file.static org.eclipse.core.resources.IFile
getFile(String fullPath)
Get a file from the workspace.static String
getNameWithoutExtension(File file)
Get the name of a file without its extension.static void
move(File source, File target)
Move a file.static void
move(org.eclipse.emf.common.util.URI source, org.eclipse.emf.common.util.URI target)
Move a file.static File
replaceFileExtension(File file, String newExtension)
Replace the extension of a file with another one.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.
-
-
-
Method Detail
-
getContents
public static String getContents(org.eclipse.core.resources.IFile file)
Get contents of an Eclipse resource file as string.
-
getContents
public static String getContents(InputStream in) throws IOException
Read contents of an input stream to a string.- Throws:
IOException
-
getContents
public static String getContents(File file) throws IOException
Get contents of a Java file as string.- Throws:
IOException
-
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(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(File source, File target) throws IOException
Copy a file.- Throws:
IOException
-
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
-
createFile
public static void createFile(String name, String contents) throws IOException
Create 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.
-
-