Class FileUtil
java.lang.Object
com.ibm.wala.util.io.FileUtil
Simple utilities for accessing files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic FileOutputStreamcreateFile(String fileName) Create aFileOutputStreamcorresponding to a particular file name.static voiddeleteContents(String directory) delete all files (recursively) in a directory.static Collection<File> List all the files in a directory that match a regular expressionstatic byte[]read fully the contents of s and return a byte array holding the resultstatic voidstatic voidwrite string s into file f
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
listFiles
public static Collection<File> listFiles(String dir, @Language("RegExp") String regex, boolean recurse) List all the files in a directory that match a regular expression- Parameters:
recurse- recurse to subdirectories?- Throws:
IllegalArgumentException- if dir is null
-
copy
This may be a resource leak.We may have to reconsider using nio for this, or apply one of the horrible workarounds listed in the bug report above.
- Throws:
IOException
-
deleteContents
delete all files (recursively) in a directory. This is dangerous. Use with care.- Throws:
IOException- if there's a problem deleting some file
-
createFile
Create aFileOutputStreamcorresponding to a particular file name. Delete the existing file if one exists.- Throws:
IOException
-
readBytes
read fully the contents of s and return a byte array holding the result- Throws:
IOException
-
writeFile
write string s into file f- Throws:
IOException
-
recurseFiles
-