Class FileUtil

  • public class FileUtil
    extends java.lang.Object
    A file utility class
    • Constructor Summary

      Constructor Description
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] createChecksum​( filename, java.lang.String digestAlgorithm)  
      static void createSymlink​(java.lang.String targetPathStr, symlinkFile)  
      static LimitedDosFileAttributes dosAttrsFromString​(java.lang.String dosFileAttributes)  
      static java.lang.String dosAttrsToString​(java.nio.file.attribute.DosFileAttributes dosFileAttributes)  
      static boolean exists​( file)
      Replaces the exists() method in the File class by taking symlinks into account.
      static java.lang.String formatFileSize​(long size)  
      static getCanonicalFile​( file)  
      static java.lang.String getDatabasePath​(java.lang.String filePath)  
      static java.lang.String getRelativeDatabasePath​( base, file)  
      static java.lang.String getRelativePath​( base, file)  
      static boolean isDirectory​( file)  
      static boolean isFileLocked​( file)  
      static boolean isSymlink​( file)  
      static java.lang.String readSymlinkTarget​( file)  
      static java.lang.String removeTrailingSlash​(java.lang.String filename)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRelativePath

        public static java.lang.String getRelativePath​( base,
      • getRelativeDatabasePath

        public static java.lang.String getRelativeDatabasePath​( base,
      • getDatabasePath

        public static java.lang.String getDatabasePath​(java.lang.String filePath)
      • removeTrailingSlash

        public static java.lang.String removeTrailingSlash​(java.lang.String filename)
      • getCanonicalFile

        public static getCanonicalFile​( file)
      • createChecksum

        public static byte[] createChecksum​( filename,
                                            java.lang.String digestAlgorithm)
      • isFileLocked

        public static boolean isFileLocked​( file)
      • isSymlink

        public static boolean isSymlink​( file)
      • readSymlinkTarget

        public static java.lang.String readSymlinkTarget​( file)
      • createSymlink

        public static void createSymlink​(java.lang.String targetPathStr,
                                  throws java.lang.Exception
      • dosAttrsToString

        public static java.lang.String dosAttrsToString​(java.nio.file.attribute.DosFileAttributes dosFileAttributes)
      • exists

        public static boolean exists​( file)
        Replaces the exists() method in the File class by taking symlinks into account. The method returns true if the file exists, false otherwise.

        Note: The method returns true, if a symlink exists, but points to a non-existing target. This behavior is different from the classic exists()-method in the File class.

        file - A file
        Returns true if a file exists (even if its symlink target does not), false otherwise
      • isDirectory

        public static boolean isDirectory​( file)
      • formatFileSize

        public static java.lang.String formatFileSize​(long size)