Package com.orientechnologies.common.io
Class OFileUtils
java.lang.Object
com.orientechnologies.common.io.OFileUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidatomicMoveWithFallback(Path source, Path target, Object requester) Tries to move a file from the source to the target atomically.static voidcheckValidName(String iFileName) static final voidcopyDirectory(File source, File destination) static final voidstatic voidcreateDirectoryTree(String iFileName) static booleanstatic voiddeleteFolderIfEmpty(File dir) static voiddeleteRecursively(File rootFile) static voiddeleteRecursively(File rootFile, boolean onlyDirs) static StringgetDirectory(String iPath) static Stringstatic longgetSizeAsNumber(Object iSize) static StringgetSizeAsString(long iSize) static voidprepareForFileCreationOrReplacement(Path path, Object requester, String operation) Prepares the path for a file creation or replacement.static booleanrenameFile(File from, File to) static Numberstring2number(String iText)
-
Field Details
-
KILOBYTE
public static final int KILOBYTE- See Also:
-
MEGABYTE
public static final int MEGABYTE- See Also:
-
GIGABYTE
public static final int GIGABYTE- See Also:
-
TERABYTE
public static final long TERABYTE- See Also:
-
-
Constructor Details
-
OFileUtils
public OFileUtils()
-
-
Method Details
-
getSizeAsNumber
-
string2number
-
getSizeAsString
-
getDirectory
-
createDirectoryTree
-
getPath
-
checkValidName
- Throws:
IOException
-
deleteRecursively
-
deleteRecursively
-
deleteFolderIfEmpty
-
copyFile
- Throws:
IOException
-
copyDirectory
- Throws:
IOException
-
renameFile
- Throws:
IOException
-
delete
- Throws:
IOException
-
prepareForFileCreationOrReplacement
public static void prepareForFileCreationOrReplacement(Path path, Object requester, String operation) throws IOException Prepares the path for a file creation or replacement. If the file pointed by the path already exists, it will be deleted, a warning will be emitted to the log in this case. All absent directories along the path will be created.- Parameters:
path- the file path.requester- the requester of an operation being performed to produce user-friendly log messages.operation- the description of an operation being performed to produce user-friendly log messages. Use descriptions like "exporting", "backing up", etc.- Throws:
IOException
-
atomicMoveWithFallback
public static void atomicMoveWithFallback(Path source, Path target, Object requester) throws IOException Tries to move a file from the source to the target atomically. If atomic move is not possible, falls back to regular move.- Parameters:
source- the source to move the file from.target- the target to move the file to.requester- the requester of the move being performed to produce user-friendly log messages.- Throws:
IOException- See Also:
-