Class OFileUtils

java.lang.Object
com.orientechnologies.common.io.OFileUtils

public class OFileUtils extends Object
  • Field Details

  • Constructor Details

    • OFileUtils

      public OFileUtils()
  • Method Details

    • getSizeAsNumber

      public static long getSizeAsNumber(Object iSize)
    • string2number

      public static Number string2number(String iText)
    • getSizeAsString

      public static String getSizeAsString(long iSize)
    • getDirectory

      public static String getDirectory(String iPath)
    • createDirectoryTree

      public static void createDirectoryTree(String iFileName)
    • getPath

      public static String getPath(String iPath)
    • checkValidName

      public static void checkValidName(String iFileName) throws IOException
      Throws:
      IOException
    • deleteRecursively

      public static void deleteRecursively(File rootFile)
    • deleteRecursively

      public static void deleteRecursively(File rootFile, boolean onlyDirs)
    • deleteFolderIfEmpty

      public static void deleteFolderIfEmpty(File dir)
    • copyFile

      public static final void copyFile(File source, File destination) throws IOException
      Throws:
      IOException
    • copyDirectory

      public static final void copyDirectory(File source, File destination) throws IOException
      Throws:
      IOException
    • renameFile

      public static boolean renameFile(File from, File to) throws IOException
      Throws:
      IOException
    • delete

      public static boolean delete(File file) throws IOException
      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: