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 boolean |
isFileExist(String filePath)
Check if file exist in given file path
|
static String |
readFile(String filePath,
String fileName)
Read content from a given file
|
static <T> T |
readYamlFile(String location,
Class<T> type)
Returns an instance of the specified type from the given configuration YAML.
|
static void |
removeFile(String filePath)
Remove file if exist by given file path
|
static void |
saveFile(String content,
String filePath,
boolean append)
Saves the content to a file with the given file path.
|
static void |
saveFile(String content,
String filePath,
String fileName,
boolean append)
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 IOException
directory - the directory in which the files should be look-upglob - the glob pattern to be filteredIOException - thrown when an error occurred while accessing files on directory.public static void saveFile(String content, String filePath, String fileName, boolean append) throws IOException
content - content to write in the filefilePath - location to save the filefileName - name of the fileappend - true if append, false if overwriteIOException - thrown when error on persisting filepublic static void saveFile(String content, String filePath, boolean append) throws IOException
content - The content to save into filefilePath - Whole file path to writeappend - true if append, false if overwriteIOException - thrown when error on persisting filepublic static boolean isFileExist(String filePath)
filePath - The file pathpublic static void removeFile(String filePath) throws TestGridException
filePath - File path to removeTestGridException - File deleting exceptionpublic static String readFile(String filePath, String fileName) throws TestGridException
filePath - The file path to writefileName - name of the fileTestGridException - Throw when file reading errorpublic 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 © 2019 WSO2. All rights reserved.