Class FileUtil

java.lang.Object
com.infoteria.asteria.util.file.FileUtil

public class FileUtil extends Object
ファイルを扱うためのユーティリティクラスです。
  • Field Details

    • TRANSFER_SIZE

      public static int TRANSFER_SIZE
  • Constructor Details

    • FileUtil

      public FileUtil()
  • Method Details

    • replaceSeparator

      public static String replaceSeparator(String path)
      separatorCharをプラットフォームの文字に変換します。
    • normalizeSeparator

      public static String normalizeSeparator(String path)
      separatorCharを「/」に統一します。
    • readFile

      public static byte[] readFile(File file) throws IOException
      ファイルをバイト配列に読み込みます。
      Throws:
      IOException
    • writeFile

      public static void writeFile(File file, byte[] data) throws IOException
      バイト配列をファイルに書き込みます。
      Throws:
      IOException
    • copy

      public static boolean copy(File src, File dest) throws IOException
      copy(src, dest, true, true)と同じです。
      Throws:
      IOException
    • copy

      public static boolean copy(File src, File dest, boolean overwrite) throws IOException
      copy(src, dest, overwrite, true)と同じです。
      Throws:
      IOException
    • copy

      public static boolean copy(File src, File dest, boolean overwrite, boolean keepLastModified) throws IOException
      ファイルをコピーします。
      Parameters:
      src - コピー元ファイル
      dest - コピー先ファイル
      overwrite - コピー先ファイルが存在する時に上書きするかどうかを指定します
      keepLastModified - コピー時にファイルのタイムスタンプを維持するかどうかを指定します。
      Returns:
      ファイルのコピーに成功した場合はtrue
      Throws:
      IOException
    • updateFile

      public static void updateFile(String filename, byte[] data) throws IOException
      ファイルを更新します。
      同じ名前のファイルが存在する場合は元のファイルは「ファイル名.bak」という名前で1世代バックアップされます。
      Parameters:
      filename - ファイル名
      data - ファイルデータ
      Throws:
      IOException - 更新に失敗した場合
    • getRelativePath

      public static String getRelativePath(File base, File file)
      fileのbaseからの相対パスを返します。
    • deleteRecursive

      public static boolean deleteRecursive(File file)
      fileがディレクトリの場合、中身まで含めて削除します。
    • getExt

      public static String getExt(File f)
      ファイルの拡張子を取得します
    • isEmptyDirectory

      public static boolean isEmptyDirectory(File dir)
      ディレクトリの場合空のディレクトリかどうかを返します
      Parameters:
      dir - 確認対象のディレクトリ
      Returns:
      true : 空のディレクトリです , false : ファイルが存在します
    • getFileList

      public static List<File> getFileList(File path) throws IllegalStateException
      Throws:
      IllegalStateException
    • getFileList

      public static List<File> getFileList(String[] paths)
    • isFileSystemCaseSensitive

      public static boolean isFileSystemCaseSensitive()
    • hasWildcards

      public static boolean hasWildcards(File file)
    • hasWildcards

      public static boolean hasWildcards(String path)