Package berlin.yuna.clu.logic
Class SystemUtil
- java.lang.Object
-
- berlin.yuna.clu.logic.SystemUtil
-
public class SystemUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static OsTypeOSstatic OsArchOS_ARCHstatic OsArchTypeOS_ARCH_TYPEstatic StringTMP_DIR
-
Constructor Summary
Constructors Constructor Description SystemUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PathcopyResourceToTemp(Class<?> clazz, String relativePath)Copies a source file to temp path as the resources are not accessible/executablestatic booleandeleteDirectory(Path path)Deletes silent a directorystatic voidkillProcessByName(String name)kills processes by namestatic StringreadFile(Path path)Reads in a whole filestatic List<String>readFileLines(Path path)Reads in a whole filestatic booleansetFilePermissions(Path path, PosixFilePermission... permissions)Sets silent file permissions (PosixFilePermissions will be mapped to filePermissions as windows doesn't understand posix)
-
-
-
Field Detail
-
TMP_DIR
public static final String TMP_DIR
-
OS
public static final OsType OS
-
OS_ARCH
public static final OsArch OS_ARCH
-
OS_ARCH_TYPE
public static final OsArchType OS_ARCH_TYPE
-
-
Method Detail
-
setFilePermissions
public static boolean setFilePermissions(Path path, PosixFilePermission... permissions)
Sets silent file permissions (PosixFilePermissions will be mapped to filePermissions as windows doesn't understand posix)- Parameters:
path- Path to set permissions onpermissions- permission list to set for the given Path- Returns:
- true if no error occurred and if permissions are set successfully
-
copyResourceToTemp
public static Path copyResourceToTemp(Class<?> clazz, String relativePath)
Copies a source file to temp path as the resources are not accessible/executable- Parameters:
clazz- Caller class to find its resource / get its classloaderrelativePath- relative resource file path- Returns:
- temp path from copied file output
-
readFile
public static String readFile(Path path)
Reads in a whole file- Parameters:
path- Filepath to read from- Returns:
- File content
-
readFileLines
public static List<String> readFileLines(Path path)
Reads in a whole file- Parameters:
path- Filepath to read from- Returns:
- File content line wise
-
deleteDirectory
public static boolean deleteDirectory(Path path)
Deletes silent a directory- Parameters:
path- directory to delete- Returns:
- false on exception and any deletion error
-
killProcessByName
public static void killProcessByName(String name)
kills processes by name- Parameters:
name- name of the process to kill
-
-