public final class FileUtils extends Object
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String[] |
getResourceListing(Class<?> clazz,
String path)
List directory contents for a resource folder.
|
static String |
read(String file)
Consume the content of the specified text file and return it as a string.
|
static void |
replaceERE(String file,
String ere,
String replacement)
Utility to replace a given ERE in the specified file with a replacement
string.
|
static boolean |
replaceFile(String file,
String toFile)
Safely moves one file over another.
|
static void |
write(InputStream fileStream,
File file)
Write the given input stream of data to the specified file
|
static void |
write(String file,
String data)
Write the given data into the specified text file.
|
public static void replaceERE(String file, String ere, String replacement) throws IOException
file - file to search and replace patterns withinere - extended regular expression to be replacedreplacement - replacement stringIOException - if issues encountered while reading original or
writing replacementpublic static boolean replaceFile(String file, String toFile)
file - source filetoFile - target file to which the source file should be movedpublic static String read(String file) throws IOException
file - file path of the file to be readIOException - if issues encountered while reading filepublic static void write(String file, String data) throws IOException
file - file path of the file to be writtendata - to be writtenIOException - if issues encountered while reading filepublic static void write(InputStream fileStream, File file) throws IOException
fileStream - the input stream containing the data to be writtenfile - The file to be written toIOException - if issues encountered while writing the filepublic static String[] getResourceListing(Class<?> clazz, String path) throws URISyntaxException, IOException
clazz - Any java class that lives in the same place as the
resources you want.path - Should end with "/", but not start with one.URISyntaxException - if the given path forms bad URLIOException - if issues arise reading the requested resourceIllegalArgumentException - if path starts with a slashCopyright © 2014. All Rights Reserved.