Class FilesystemManager
java.lang.Object
com.idmedia.translationstudio.impl.util.FilesystemManager
- All Implemented Interfaces:
IFilesystemManager
bundles operations on the filesystem
- Author:
- I-D Media AG
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanTempDirectory
(File pTempDir) Cleanup Filesystemstatic boolean
Clone a fileboolean
Copy source to target file.createBackupFile
(File pFileToBackup) Creates a backup filecreateTempDirectory
(IConfiguration pConfig) create a new temporary directory in a given master temp directoryboolean
deleteFile
(File pFile) Deletes a filestatic boolean
Check if a given file exitsstatic boolean
boolean
fileExists
(File pFile) Checks if File exists and is a fileboolean
Move source to target file.static byte[]
readFileAsBytes
(File pFile) readFileUtf8
(File pFile) Read a filereadFileUtf8
(String sPath) Read a file in UTF-8readFileUtf8AsBuilder
(String sPath) Read a file in UTF-8boolean
removeDirectory
(File pDirectory) Delete a directorystatic boolean
removeFile
(File pFile) Delete a Fileboolean
renameFile
(File pSrcFile, File pDstFile) Rename a filestatic boolean
Write a file in UTF-8static boolean
Write a file in UTF-8boolean
writeFileUtf8
(String sTargetFile, byte[] pContent, boolean bAppendData) Write a file in UTF-8boolean
writeFileUtf8
(String sFile, String sContent) Write a file in UTF-8boolean
writeFileUtf8
(String sTargetFile, StringBuilder psContent, boolean bAppend) Write a file in UTF-8boolean
writeFileUtf8
(String sTargetFile, String sContent, boolean bAppendData) Write a file in UTF-8
-
Constructor Details
-
FilesystemManager
public FilesystemManager()
-
-
Method Details
-
removeDirectory
Delete a directory- Specified by:
removeDirectory
in interfaceIFilesystemManager
- Parameters:
pDirectory
- Input Directory- Returns:
- success state
-
removeFile
Delete a File- Parameters:
pFile
- Input Directory- Returns:
- success state
-
writeFileUtf8
Write a file in UTF-8- Specified by:
writeFileUtf8
in interfaceIFilesystemManager
- Parameters:
sFile
- Target File, will be created if necessarysContent
- Content- Returns:
- success state
-
writeFileUtf8
public boolean writeFileUtf8(@Nullable String sTargetFile, @Nullable String sContent, boolean bAppendData) Write a file in UTF-8- Specified by:
writeFileUtf8
in interfaceIFilesystemManager
- Parameters:
sTargetFile
- Target File, will be created if necessarysContent
- ContentbAppendData
- Append Data to existing content- Returns:
- success state
-
writeFileUtf8
public boolean writeFileUtf8(@Nullable String sTargetFile, @Nullable StringBuilder psContent, boolean bAppend) Write a file in UTF-8- Specified by:
writeFileUtf8
in interfaceIFilesystemManager
- Parameters:
sTargetFile
- Target File, will be created if necessarypsContent
- ContentbAppend
- Append to the file if true, otherwise write create new file- Returns:
- success state
-
writeFileUtf8
public boolean writeFileUtf8(@Nullable String sTargetFile, @Nullable byte[] pContent, boolean bAppendData) Write a file in UTF-8- Specified by:
writeFileUtf8
in interfaceIFilesystemManager
- Parameters:
sTargetFile
- Target File, will be created if necessarypContent
- ContentbAppendData
- Append Data to existing content- Returns:
- success state
-
writeFile
public static boolean writeFile(@Nullable String sTargetFile, @Nullable String sContent, boolean bAppend) Write a file in UTF-8- Parameters:
sTargetFile
- Target File, will be created if necessarysContent
- ContentbAppend
- if true append to file, otherwise create a new file- Returns:
- success state
-
writeFile
public static boolean writeFile(@NotNull File pTargetFile, @NotNull byte[] byteContent, boolean bAppend) Write a file in UTF-8- Parameters:
pTargetFile
- Target File, will be created if necessarybyteContent
- bytes to writebAppend
- if true append to file, otherwise create a new file- Returns:
- success state
-
createBackupFile
Creates a backup file- Parameters:
pFileToBackup
-- Returns:
- backuped file
- Throws:
IOException
-
deleteFile
Deletes a file- Specified by:
deleteFile
in interfaceIFilesystemManager
- Parameters:
pFile
-- Returns:
- success state
-
renameFile
Rename a file- Parameters:
pSrcFile
-pDstFile
-- Returns:
-
fileExists
Checks if File exists and is a file- Specified by:
fileExists
in interfaceIFilesystemManager
- Parameters:
pFile
- File to be checked- Returns:
- result
-
readFileAsBytes
-
readFileUtf8
Description copied from interface:IFilesystemManager
Read a file- Specified by:
readFileUtf8
in interfaceIFilesystemManager
- Returns:
-
readFileUtf8AsBuilder
Read a file in UTF-8- Specified by:
readFileUtf8AsBuilder
in interfaceIFilesystemManager
- Parameters:
sPath
- File to be read- Returns:
- Content or
null
on error
-
readFileUtf8
Read a file in UTF-8- Specified by:
readFileUtf8
in interfaceIFilesystemManager
- Parameters:
sPath
- File to be read- Returns:
- Content or
null
on error
-
exists
Check if a given file exits- Parameters:
pFile
- File to check- Returns:
-
exists
-
cloneFile
Clone a file- Parameters:
pSourceFile
- Source file namepTargetFile
- Target file name- Returns:
- success state
-
moveFiles
Move source to target file. Target file will overwritten- Specified by:
moveFiles
in interfaceIFilesystemManager
- Returns:
-
copyFile
Copy source to target file. Target file will overwritten- Specified by:
copyFile
in interfaceIFilesystemManager
- Returns:
-
cleanTempDirectory
Cleanup FilesystemIn debug mode the temporary files are left in place to allow better analysis of the process.
- Specified by:
cleanTempDirectory
in interfaceIFilesystemManager
- Parameters:
pTempDir
-
-
createTempDirectory
Description copied from interface:IFilesystemManager
create a new temporary directory in a given master temp directory- Specified by:
createTempDirectory
in interfaceIFilesystemManager
- Returns:
- New Directory Handler or null
-