Class FileUtil

java.lang.Object
jp.ecuacion.lib.core.util.FileUtil

public class FileUtil extends Object
Provides File-related utility methods.
  • Constructor Details

    • FileUtil

      public FileUtil()
  • Method Details

    • getFileSavableName

      @Nonnull public String getFileSavableName(@RequireNonnull String origName)
      Changes argument filename into file-savable name.
    • concatFilePaths

      @Nonnull public String concatFilePaths(@Nonnull String... paths)
      Concatenates file paths.
      Parameters:
      paths - paths
      Returns:
      the concatenated path
    • cleanPathStrWithSlash

      @Nonnull public String cleanPathStrWithSlash(@RequireNonnull String path)
      Cleans a path string.

      Paths like /path//to\file change to the clean format like /path/to/file.
      Separator is always / even if this method is called in Windows OS.

      Parameters:
      path - path
      Returns:
      the cleaned path
    • isLocked

      public boolean isLocked(@RequireNonnull String path) throws IOException
      Checks if file is locked.
      Parameters:
      path - path, Both absolute and relativve path is acceptable.
      Returns:
      true when file is locked.
      Throws:
      IOException - IOException
    • containsWildCard

      public boolean containsWildCard(String path)
      Returns true if the argument path contains wildcard strings.
    • getPathListFromPathWithWildcard

      public List<String> getPathListFromPathWithWildcard(String path) throws BizLogicAppException
      Returns a list of paths which match the path passed by the argument path with wildcards.

      "*", "?" are supported, but "**" not supported.
      The separator of returning Paths is "/"

      Throws:
      BizLogicAppException
    • isRelativePath

      public boolean isRelativePath(String path) throws BizLogicAppException
      Returns true if the path is relative.
      Parameters:
      path - path
      Returns:
      true if the path is relative
      Throws:
      BizLogicAppException - BizLogicAppException
    • getParentDirPath

      public String getParentDirPath(String origPath)
      Changes the path separator to "/".
      Parameters:
      origPath - original path
      Returns:
      the separator changed path
    • getFileNameFromFilePath

      public String getFileNameFromFilePath(String path)
      Obtains filename from a path.

      Both "/" and "\" are treated as the separator.

      Parameters:
      path - path
      Returns:
      filename
    • getFileSizeInMb

      public String getFileSizeInMb(Long fileSize)
      Returns file size in Megabyte.
      Parameters:
      fileSize - fileSize
      Returns:
      the file size in Megabyte
    • getFileSizeInMbWithUnit

      public String getFileSizeInMbWithUnit(Long fileSize)
      Returns file size in Megabyte.
      Parameters:
      fileSize - fileSize
      Returns:
      the file size in Megabyte