Class FileUtils
- java.lang.Object
-
- io.jenkins.plugins.google.analyze.code.security.utils.FileUtils
-
public final class FileUtils extends Object
Utility class for report generation helper methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileInfo
loadFileFromWorkspace(@NonNull FilePath root, @NonNull String fileName, String filePath)
Finds file in the workspace and reads its contents.static String
readFromInputStream(InputStream inputStream)
Reads stream contents and returns them as string.static String
readResource(String filePath)
Reads a resource present on the resource directory.
-
-
-
Method Detail
-
loadFileFromWorkspace
public static FileInfo loadFileFromWorkspace(@NonNull @NonNull FilePath root, @NonNull @NonNull String fileName, String filePath) throws IOException, InterruptedException
Finds file in the workspace and reads its contents.- Parameters:
root
- base directory of the jenkins workspace.fileName
- file name.filePath
- file path relative to workspace root directory.- Returns:
- file info comprising file contents and file path.
- Throws:
IOException
- exception occurred during reading file.InterruptedException
- thrown when execution thread is interrupted.
-
readResource
public static String readResource(String filePath) throws IOException
Reads a resource present on the resource directory.- Parameters:
filePath
- location of the file w.r.t. resource directory in the project.- Returns:
- file contents as string.
- Throws:
IOException
- if the file is not found on the path.
-
readFromInputStream
public static String readFromInputStream(InputStream inputStream) throws IOException
Reads stream contents and returns them as string.- Throws:
IOException
- if failure occurs while reading stream contents.
-
-