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(@Nonnull 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(@Nonnull 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(@Nonnull 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)
      パス文字列中にワイルドカードが含まれるかどうかをチェック.
    • getPathListFromPathWithWildcard

      public List<String> getPathListFromPathWithWildcard(String path) throws BizLogicAppException
      wildcardつきfullPathを引数にとり、そのfullPathに当てはまるfullPathのリストを返す.
      「*」と「?」はサポートしているが、サブディレクトリを含めて検索する「**」はサポートしていない
      ワイルドカードを扱う場合は、区切り文字が「/」と「\」の2種類があると煩雑なため、「/」に統一して処理を行う
      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