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 boolean
cleanFolder(java.io.File parentFolder, java.io.FileFilter filter, boolean continueOnError, boolean deleteParentFolder)
Clean the content of the given folder.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.static java.lang.String
readFileIntoString(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.String
readStreamIntoString(java.io.InputStream inputStream)
static boolean
sweepFolder(java.io.File folder)
This will completely sweep the given folder.static void
writeStringIntoFile(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.FileNotFoundException
Clean 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 ifparentFolder
should be also deleted if it becomes empty.- Returns:
true
if the cleaning process goes through all the folders and files.false
if the process has been stopped before its termination. The valuefalse
could be replied only if the value ofcontinueOnError
isfalse
.- Throws:
java.io.FileNotFoundException
- if the givenparentFolder
does not exists.
-
sweepFolder
public static boolean sweepFolder(java.io.File folder) throws java.io.FileNotFoundException
This 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:
true
if 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)
-
-