Package com.infoteria.asteria.util.file
Class FileUtil
java.lang.Object
com.infoteria.asteria.util.file.FileUtil
ファイルを扱うためのユーティリティクラスです。
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancopy(src, dest, true, true)と同じです。static booleancopy(src, dest, overwrite, true)と同じです。static booleanファイルをコピーします。static booleandeleteRecursive(File file) fileがディレクトリの場合、中身まで含めて削除します。static Stringファイルの拡張子を取得しますgetFileList(File path) getFileList(String[] paths) static StringgetRelativePath(File base, File file) fileのbaseからの相対パスを返します。static booleanhasWildcards(File file) static booleanhasWildcards(String path) static booleanisEmptyDirectory(File dir) ディレクトリの場合空のディレクトリかどうかを返しますstatic booleanstatic StringnormalizeSeparator(String path) separatorCharを「/」に統一します。static byte[]ファイルをバイト配列に読み込みます。static StringreplaceSeparator(String path) separatorCharをプラットフォームの文字に変換します。static voidupdateFile(String filename, byte[] data) ファイルを更新します。
同じ名前のファイルが存在する場合は元のファイルは「ファイル名.bak」という名前で1世代バックアップされます。static voidバイト配列をファイルに書き込みます。
-
Field Details
-
TRANSFER_SIZE
public static int TRANSFER_SIZE
-
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
replaceSeparator
separatorCharをプラットフォームの文字に変換します。 -
normalizeSeparator
separatorCharを「/」に統一します。 -
readFile
ファイルをバイト配列に読み込みます。- Throws:
IOException
-
writeFile
バイト配列をファイルに書き込みます。- Throws:
IOException
-
copy
copy(src, dest, true, true)と同じです。- Throws:
IOException
-
copy
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
ファイルを更新します。
同じ名前のファイルが存在する場合は元のファイルは「ファイル名.bak」という名前で1世代バックアップされます。- Parameters:
filename- ファイル名data- ファイルデータ- Throws:
IOException- 更新に失敗した場合
-
getRelativePath
fileのbaseからの相対パスを返します。 -
deleteRecursive
fileがディレクトリの場合、中身まで含めて削除します。 -
getExt
ファイルの拡張子を取得します -
isEmptyDirectory
ディレクトリの場合空のディレクトリかどうかを返します- Parameters:
dir- 確認対象のディレクトリ- Returns:
- true : 空のディレクトリです , false : ファイルが存在します
-
getFileList
- Throws:
IllegalStateException
-
getFileList
-
isFileSystemCaseSensitive
public static boolean isFileSystemCaseSensitive() -
hasWildcards
-
hasWildcards
-