类 CmsFileUtils

java.lang.Object
com.publiccms.common.tools.CmsFileUtils

public class CmsFileUtils extends Object
CmsFileUtils 文件操作组件
  • 字段详细资料

  • 构造器详细资料

    • CmsFileUtils

      private CmsFileUtils()
  • 方法详细资料

    • getFileList

      public static List<CmsFileUtils.FileInfo> getFileList(String dirPath, String orderField)
      获取目录下文件列表 Get file list in directory ディレクトリ内のファイルリストを取得します
      参数:
      dirPath -
      orderField -
      返回:
      file info list
    • searchFileList

      public static List<CmsFileUtils.FileSearchResult> searchFileList(String dirPath, String parentPath, String word)
      获取目录下文件列表 Get file list in directory ディレクトリ内のファイルリストを取得します
      参数:
      dirPath -
      parentPath -
      word -
      返回:
      file result list
    • replaceFileList

      public static void replaceFileList(String dirPath, List<CmsFileUtils.FileReplaceResult> fileList, String word, String replace)
      获取目录下文件列表 Get file list in directory ディレクトリ内のファイルリストを取得します
      参数:
      dirPath -
      fileList -
      word -
      replace -
    • searchFileList

      private static void searchFileList(Path dirPath, String parentPath, String word, List<CmsFileUtils.FileSearchResult> fileList)
      获取目录下文件列表 Get file list in directory ディレクトリ内のファイルリストを取得します
      参数:
      dirPath -
      parentPath -
      word -
      fileList -
    • getFileList

      public static List<CmsFileUtils.FileInfo> getFileList(String dirPath, boolean useFilter, String orderField)
      获取目录下文件列表 Get file list in directory ディレクトリ内のファイルリストを取得します
      参数:
      dirPath -
      useFilter -
      orderField -
      返回:
      file info list
    • writeByteArrayToFile

      public static void writeByteArrayToFile(String filepath, byte[] data) throws IOException
      将字节数组写入文件 Write byte array to file バイト配列をファイルに書き込みます
      参数:
      filepath -
      data -
      抛出:
      IOException
    • getFileSize

      public static FileUploadResult getFileSize(String filepath, String filename, String suffix)
      获取文件大小 Get file size ファイルサイズを取得します
      参数:
      filepath -
      filename -
      suffix -
      返回:
      uploadResult
    • getFileSize

      private static FileUploadResult getFileSize(File file, String filename, String suffix)
      获取文件大小 Get file size ファイルサイズを取得します
      参数:
      file -
      suffix -
      返回:
      uploadResult
    • copyInputStreamToFile

      public static void copyInputStreamToFile(InputStream source, String destination) throws IOException
      将输入流复制到文件 Copy input stream to file 入力ストリームをファイルにコピーします
      参数:
      source -
      destination -
      抛出:
      IOException
    • copyFileToFile

      public static void copyFileToFile(String source, String destination) throws IOException
      将文件复制到文件 Copy file to file ファイルをファイルにコピーします
      参数:
      source -
      destination -
      抛出:
      IOException
    • copyFileToOutputStream

      public static void copyFileToOutputStream(String filepath, OutputStream outputStream) throws IOException
      将文件复制到输出流 Copy file to output stream ファイルを出力ストリームにコピーします
      参数:
      filepath -
      outputStream -
      抛出:
      IOException
    • mkdirs

      public static void mkdirs(String filepath)
      创建目录 Create directory ディレクトリを作成します
      参数:
      filepath -
    • mkdirsParent

      public static void mkdirsParent(String filepath)
      创建父目录 Create parent directory 親ディレクトリを作成します
      参数:
      filepath -
    • isDirectory

      public static boolean isDirectory(String filepath)
      判断是否为目录 Check if it is a directory ディレクトリであるかどうかを確認します
      参数:
      filepath -
      返回:
    • isFile

      public static boolean isFile(String filepath)
      判断是否为文件 Check if it is a file ファイルであるかどうかを確認します
      参数:
      filepath -
      返回:
    • exists

      public static boolean exists(String filepath)
      判断文件是否存在 Check if file exists ファイルが存在するかどうかを確認します
      参数:
      filepath -
      返回:
    • createFile

      public static boolean createFile(String filepath, String content) throws IOException
      写入文件 Write to file ファイルに書き込みます
      参数:
      filepath -
      content -
      返回:
      whether to create successfully
      抛出:
      IOException
    • moveFile

      public static boolean moveFile(String filepath, String backupFilePath)
      移动文件或目录 Move file or directory ファイルまたはディレクトリを移動します
      参数:
      filepath -
      backupFilePath -
      返回:
      whether to move successfully
    • getSafeFileName

      public static String getSafeFileName(String path)
      获取安全的文件名 Get safe file name セーフなファイル名を取得します
      参数:
      path -
      返回:
      safe file path
    • delete

      public static boolean delete(String filepath)
      删除文件或目录 Delete file or directory ファイルまたはディレクトリを削除します
      参数:
      filepath -
      返回:
      whether to move successfully
    • updateFile

      public static boolean updateFile(String filepath, String historyFilePath, String content) throws IOException
      修改文件内容 Update file content ファイルの内容を更新します
      参数:
      filepath -
      historyFilePath -
      content -
      返回:
      whether to modify successfully
      抛出:
      IOException
    • isSafe

      public static boolean isSafe(String filepath, String suffix)
      判断文件是否安全 Check if file is safe ファイルが安全であるかどうかを確認します
      参数:
      filepath -
      suffix -
      返回:
      is safe
    • isSafe

      private static boolean isSafe(List<org.apache.pdfbox.cos.COSObject> pdfObjects)
    • getFileContent

      public static String getFileContent(String filepath)
      获取文件内容 Get file content ファイルの内容を取得します
      参数:
      filepath -
      suffix -
      返回:
      file content
    • getUploadFileName

      public static String getUploadFileName(String suffix)
      获取上传文件名 Get upload file name アップロードファイル名を取得します
      参数:
      suffix -
      返回:
      upload file name
    • getPrivateFileSignString

      public static String getPrivateFileSignString(long expiry, String filepath)
      获取私有文件签名字符串 Get private file sign string 私有ファイルの署名文字列を取得します
      参数:
      expiry -
      filepath -
      返回:
      avatar file name
    • getUserPrivateFileName

      public static String getUserPrivateFileName(long userId, String filepath)
      获取用户私有文件名 Get user private file name ユーザーのプライベートファイル名を取得します
      参数:
      userId -
      filepath -
      返回:
      user private file name
    • getFileName

      public static String getFileName(String filePath)
      获取文件名 Get file name ファイル名を取得します
      参数:
      filePath -
      返回:
      suffix
    • getSuffix

      public static String getSuffix(String originalFilename)
      获取文件后缀 Get file suffix ファイルのサフィックスを取得します
      参数:
      originalFilename -
      返回:
      suffix
    • getFileType

      public static String getFileType(String suffix)
      获取文件类型 Get file type ファイルタイプを取得します
      参数:
      suffix -
      返回:
      file type
    • upload

      public static String upload(byte[] data, String fileName) throws IllegalStateException, IOException
      上传文件 Upload file ファイルをアップロードします
      参数:
      data -
      fileName -
      返回:
      file name
      抛出:
      IllegalStateException
      IOException
    • upload

      public static String upload(byte[] data, String fileName, String originalName, String metadataPath) throws IllegalStateException, IOException
      上传文件 Upload file ファイルをアップロードします
      参数:
      data -
      fileName -
      originalName -
      metadataPath -
      返回:
      file name
      抛出:
      IllegalStateException
      IOException
    • upload

      public static Path upload(org.springframework.web.multipart.MultipartFile file, String fileName) throws IOException
      上传文件 Upload file ファイルをアップロードします
      参数:
      file -
      fileName -
      返回:
      file name
      抛出:
      IOException