Class FileUtils
- java.lang.Object
-
- science.aist.jack.persistence.filesystem.FileUtils
-
public class FileUtils extends Object
Utility class for files
- Since:
- 2.0
- Author:
- Christoph Praschl
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Path
createTempDirectory(String directoryHierarchy)
Method which creates a directory in the temp folder based on the given directoryHierarchy (subfolder separated byFile.separator
)static Path
createTempFile(String fileName, String fileExtension)
Creates a file in the temp folderstatic Path
createTempFile(String dirPath, String fileName, String fileExtension)
Creates a file in a subfolder (respectively directory hierarchy) of the temp folderstatic String
toCompliantPath(String path)
Help method which creates a compliant path string usingFile.separator
, which is required by the methods ofFileUtils
static File
writeToTempFile(String fileName, String fileExtension, InputStream is)
Writes the given inputStream to a file (given by the file name and file extension) in the local TEMP directorystatic File
writeToTempFile(String dirPath, String fileName, String fileExtension, InputStream is)
Writes the given inputStream to a file (given by the file name and file extension) into a subfolder of the local TEMP directory
-
-
-
Method Detail
-
toCompliantPath
public static String toCompliantPath(String path)
Help method which creates a compliant path string usingFile.separator
, which is required by the methods ofFileUtils
- Parameters:
path
- path which contains slash "/" as file separator- Returns:
- compliant path string
-
createTempDirectory
public static Path createTempDirectory(String directoryHierarchy)
Method which creates a directory in the temp folder based on the given directoryHierarchy (subfolder separated byFile.separator
)- Parameters:
directoryHierarchy
- defining the sub folders' name- Returns:
- path to the temp directory
-
createTempFile
public static Path createTempFile(String fileName, String fileExtension)
Creates a file in the temp folder- Parameters:
fileName
- name of the file which should be createdfileExtension
- file extension of the file which should be created- Returns:
- the created file
-
createTempFile
public static Path createTempFile(String dirPath, String fileName, String fileExtension)
Creates a file in a subfolder (respectively directory hierarchy) of the temp folder- Parameters:
dirPath
- the path of the subfolderfileName
- name of the file which should be createdfileExtension
- file extension of the file which should be created- Returns:
- the created file
-
writeToTempFile
public static File writeToTempFile(String fileName, String fileExtension, InputStream is)
Writes the given inputStream to a file (given by the file name and file extension) in the local TEMP directory- Parameters:
fileName
- name of the file which should be createdfileExtension
- file extension of the file which should be createdis
- InputStream which should be written to a new file in the TEMP directory (is not closed inside of this method!); if null nothing is written to the created file- Returns:
- the created file
-
writeToTempFile
public static File writeToTempFile(String dirPath, String fileName, String fileExtension, InputStream is)
Writes the given inputStream to a file (given by the file name and file extension) into a subfolder of the local TEMP directory- Parameters:
dirPath
- Path of the subfolder in the local TEMP directory (may be null; if not useFile.separator
for separating different subfolders!)fileName
- name of the file which should be createdfileExtension
- file extension of the file which should be createdis
- InputStream which should be written to a new file in the TEMP directory (is not closed inside of this method!); if null nothing is written to the created file- Returns:
- the created file
-
-