程序包 cool.scx.util

类 FileUtils

java.lang.Object
cool.scx.util.FileUtils

public final class FileUtils extends Object
文件 操作类
版本:
0.0.1
作者:
scx567888
  • 构造器详细资料

    • FileUtils

      public FileUtils()
  • 方法详细资料

    • longToDisplaySize

      public static String longToDisplaySize(long size)
      将 long 类型的文件大小 格式化(转换为人类可以看懂的形式) 如 1024 转换为 1KB
      参数:
      size - a long.
      返回:
      a String object.
    • displaySizeToLong

      public static long displaySizeToLong(String str)
      将 格式化后的大小转换为 long 如将 1KB 转换为 1024
      参数:
      str - 待转换的值 如 5MB 13.6GB
      返回:
      a long.
    • delete

      public static void delete(Path start, FileUtils.DeleteOption... options) throws IOException
      删除文件或文件夹(会删除文件树中所有内容)
      参数:
      start - a
      options - a
      抛出:
      IOException - a
    • move

      public static void move(Path source, Path target, CopyOption... options) throws IOException
      本质上就是调用 Files.move(Path, Path, CopyOption...) ,但是在之前会创建不存在的父目录
      参数:
      source - a
      target - a
      options - a
      抛出:
      IOException - a
    • copy

      public static void copy(Path source, Path target, CopyOption... options) throws IOException
      本质上就是调用 Files.copy(Path, Path, CopyOption...) ,但是在之前会创建不存在的父目录
      参数:
      source - a
      target - a
      options - a
      抛出:
      IOException - a
    • write

      public static void write(Path path, byte[] bytes, OpenOption... options) throws IOException
      本质上就是调用 Files.write(Path, byte[], OpenOption...) ,但是在之前会创建不存在的父目录
      参数:
      path - a
      bytes - a
      options - a
      抛出:
      IOException - a
    • getFileName

      public static String getFileName(String path)

      getFileName.

      参数:
      path - a String object
      返回:
      a String object
    • getExtension

      public static String getExtension(String path)
      获取拓展名 (不包括 . ) 例 : "cat.png" 会获得 "png"
      参数:
      path - a String object
      返回:
      a String object
    • getFileNameWithoutExtension

      public static String getFileNameWithoutExtension(String path)
      获取文件名 (不包括拓展名 ) 例 : "cat.png" 会获得 "cat"
      参数:
      path - a String object
      返回:
      a String object
    • getHead

      public static String getHead(String filePath, int length) throws IOException
      获取 文件 head
      参数:
      filePath - f
      length - a int
      返回:
      r
      抛出:
      IOException - if any.