类 FileHelper

java.lang.Object
com.ajaxjs.util.io.FileHelper

public class FileHelper extends Object
  • 构造器详细资料

    • FileHelper

      public FileHelper(Path path)
    • FileHelper

      public FileHelper(File path)
    • FileHelper

      public FileHelper(String path)
  • 方法详细资料

    • getFileContent

      public String getFileContent()
      Read the file text content
      返回:
      Text content
    • readFileBytes

      public byte[] readFileBytes()
      Read the file content in bytes.
      返回:
      The file content in bytes.
    • writeFileContent

      public void writeFileContent(String content)
      将字符串内容写入文件。
      参数:
      content - 要写入的内容
      抛出:
      UncheckedIOException - 如果写入文件时发生错误
    • delete

      public void delete()
      Delete a folder or a file. If it's a folder, delete all files and sub-folders under it.
    • listDirectoryContents

      public List<String> listDirectoryContents()
      List the contents of a directory.
      返回:
      The contents of the directory.
    • createDirectory

      public void createDirectory()
      Create a directory. It can create multiple levels of directories.
    • getFileSize

      public long getFileSize()
      Get the size of a file or directory.
      返回:
      Size in bytes.
    • setTarget

      public FileHelper setTarget(File target)
    • setTarget

      public FileHelper setTarget(String target)
    • copTo

      public void copTo()
      Copy a file or directory to another location.
    • moveTo

      public void moveTo()
      Move a file or directory to another location.
    • chunkFile

      public void chunkFile(long chunkSize)
      对文件按照指定大小进行分片,在文件所在目录生成分片后的文件块儿 使用零拷贝对文件高效的切片和合并
    • mergeFile

      public void mergeFile(Path... chunkFiles)
      把多个文件合并为一个文件
      参数:
      chunkFiles - 分片文件