Package org.eclipse.xtext.util
Class Files
- java.lang.Object
-
- org.eclipse.xtext.util.Files
-
public class Files extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Files()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleancleanFolder(java.io.File parentFolder, java.io.FileFilter filter, boolean continueOnError, boolean deleteParentFolder)Clean the content of the given folder.static voidcopyFiles(java.lang.String sourceDir, java.lang.String targetDir, java.util.List<java.lang.String> files)Copies a list of files from a source to a target directory.static java.lang.StringreadFileIntoString(java.lang.String filename)Deprecated.Use com.google.common.io.Files.toString(File, Charset) insteadstatic byte[]readStreamIntoByteArray(java.io.InputStream inputStream)Deprecated.Use com.google.common.io.ByteStreams.toByteArray(InputStream) insteadstatic java.lang.StringreadStreamIntoString(java.io.InputStream inputStream)static booleansweepFolder(java.io.File folder)This will completely sweep the given folder.static voidwriteStringIntoFile(java.lang.String filename, java.lang.String content)
-
-
-
Method Detail
-
copyFiles
public static void copyFiles(java.lang.String sourceDir, java.lang.String targetDir, java.util.List<java.lang.String> files)Copies a list of files from a source to a target directory. Existing files are not overwritten. If the target directory does not exist it will be created.- Parameters:
sourceDir- source directorytargetDir- target directory. Not mandatory to exist before.files- File paths relative to the source directory to copy
-
cleanFolder
public static boolean cleanFolder(java.io.File parentFolder, java.io.FileFilter filter, boolean continueOnError, boolean deleteParentFolder) throws java.io.FileNotFoundExceptionClean the content of the given folder.- Parameters:
parentFolder- the folder to be cleaned. It must not benull.filter- a filter for selecting the files to be removed. If it isnull, all the files are removed.continueOnError- indicates if the cleaning should continue after an error occurs.deleteParentFolder- indicates ifparentFoldershould be also deleted if it becomes empty.- Returns:
trueif the cleaning process goes through all the folders and files.falseif the process has been stopped before its termination. The valuefalsecould be replied only if the value ofcontinueOnErrorisfalse.- Throws:
java.io.FileNotFoundException- if the givenparentFolderdoes not exists.
-
sweepFolder
public static boolean sweepFolder(java.io.File folder) throws java.io.FileNotFoundExceptionThis will completely sweep the given folder. Consider usingcleanFolder(File, FileFilter, boolean, boolean)if you want to preserve CVS or SVN information.- Parameters:
folder- to delete- Returns:
trueif all content was successfully deleted- Throws:
java.io.FileNotFoundException- if folder does not exists
-
readFileIntoString
@Deprecated public static java.lang.String readFileIntoString(java.lang.String filename)
Deprecated.Use com.google.common.io.Files.toString(File, Charset) instead
-
readStreamIntoByteArray
@Deprecated public static byte[] readStreamIntoByteArray(java.io.InputStream inputStream)
Deprecated.Use com.google.common.io.ByteStreams.toByteArray(InputStream) instead- Since:
- 2.3
-
readStreamIntoString
public static java.lang.String readStreamIntoString(java.io.InputStream inputStream)
-
writeStringIntoFile
public static void writeStringIntoFile(java.lang.String filename, java.lang.String content)
-
-