public class FileUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
YAML_EXTENSION |
| Constructor and Description |
|---|
FileUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
compress(String sourceDir,
String destination)
Compress the files at sourceDir into the destination zip file.
|
static void |
compressFiles(List<String> files,
String destination)
Creates a archive file of the list of files passing in the given destination.
|
static List<String> |
getFilesOnDirectory(String directory,
String glob)
This method returns the list of files in a given directory after filtering a given glob pattern.
|
static List<String> |
getTestPlanIdByReadingTGYaml(String workspace)
Get test plan ids by reading testgrid yaml files contains in the testgrid home.
|
static <T> T |
readYamlFile(String location,
Class<T> type)
Returns an instance of the specified type from the given configuration YAML.
|
static void |
saveFile(String content,
String filePath,
String fileName)
Saves the content to a file with the given name in the given file path.
|
static void |
writeToFile(String filePath,
String string)
Writes a given string to a given file to persistent media.
|
public static final String YAML_EXTENSION
public static <T> T readYamlFile(String location, Class<T> type) throws IOException
location - location of the configuration YAML fileIOException - thrown when no file is found in the given location or when error on closing file input streampublic static List<String> getFilesOnDirectory(String directory, String glob) throws TestGridException
directory - the directory in which the files should be look-upglob - the glob pattern to be filteredTestGridException - thrown when an error occurred while accessing files on directory.public static void saveFile(String content, String filePath, String fileName) throws TestGridException
content - content to write in the filefilePath - location to save the filefileName - name of the fileTestGridException - thrown when error on persisting filepublic static void compressFiles(List<String> files, String destination) throws TestGridException
files - list of files to be archivedestination - path of the archive fileTestGridExceptionpublic static void compress(String sourceDir, String destination) throws IOException
sourceDir - the source dir that has contents to archivedestination - the zip file locationIOExceptionpublic static void writeToFile(String filePath, String string) throws TestGridException
filePath - absolute path of the file to be writtenstring - string to be writtenTestGridException - thrown on FileNotFoundException or UnsupportedEncodingExceptionpublic static List<String> getTestPlanIdByReadingTGYaml(String workspace) throws TestGridException
workspace - path of the current workspaceTestGridException - thrown when IO exception on reading testgrid yaml files.Copyright © 2018 WSO2. All rights reserved.