类 FileUtil


  • public class FileUtil
    extends Object
    版本:
    v1.0,Date:2008-11-7
    作者:
    zhongxuchen
    • 方法详细资料

      • putFileInOutStream

        public static void putFileInOutStream​(OutputStream out,
                                              Object fileName)
        参数:
        out -
        fileName -
      • putInputStreamToFile

        public static void putInputStreamToFile​(InputStream is,
                                                String fileName)
        参数:
        is -
        fileName -
      • putBytesToFile

        public static void putBytesToFile​(byte[] bytes,
                                          String fileName)
        参数:
        bytes -
        fileName -
      • readFileAsStr

        public static String readFileAsStr​(Object file,
                                           String charset)
        参数:
        file -
        charset -
        返回:
      • inputStreamToStr

        public static String inputStreamToStr​(InputStream is,
                                              String encoding)
        参数:
        is -
        encoding -
        返回:
      • readLineAsStr

        public static String readLineAsStr​(File file,
                                           String charset)
      • getFileInputStream

        public static InputStream getFileInputStream​(Object file)
        参数:
        file - 文件路径like:classpath:xxx.xml或xxx.xml
        返回:
      • readAsBytes

        public static byte[] readAsBytes​(Object file)
        参数:
        file -
        返回:
      • getPathFiles

        public static void getPathFiles​(File parentFile,
                                        List fileList,
                                        String[] filters)
        参数:
        parentFile -
        fileList -
        filters -
      • getPathFiles

        public static List getPathFiles​(Object baseDir,
                                        String[] filters)
        参数:
        baseDir -
        filters -
        返回:
      • isRootPath

        public static boolean isRootPath​(String path)
        参数:
        path -
        返回:
      • createFolder

        public static void createFolder​(String folderPath)
        参数:
        folderPath - 目录
      • createFile

        public static void createFile​(String filePathAndName,
                                      String fileContent)
        参数:
        filePathAndName - 文本文件完整绝对路径及文件名
        fileContent - 文本文件内容
      • delFile

        public static boolean delFile​(String filePathAndName)
        参数:
        filePathAndName - 文本文件完整绝对路径及文件名
        返回:
        Boolean 成功删除返回true遭遇异常返回false
      • delFolder

        public static void delFolder​(String folderPath)
        参数:
        folderPath - 文件夹完整绝对路??
      • delAllFile

        public static boolean delAllFile​(String path)
        参数:
        path - 文件夹完整绝对路??
        返回:
      • deleteMatchedFile

        public static boolean deleteMatchedFile​(Object path,
                                                String[] regex)
        参数:
        path -
        regex -
        返回:
      • copyFile

        public static boolean copyFile​(String oldPathFile,
                                       String newPathFile)
        参数:
        oldPathFile - 准备复制的文件源
        newPathFile - 拷贝到新绝对路径带文件名
        返回:
      • copyFile

        public static boolean copyFile​(File oldPathFile,
                                       String newPathFile)
        参数:
        oldPathFile - 准备复制的文件源
        newPathFile - 拷贝到新绝对路径带文件名
        返回:
      • copyFolder

        public static void copyFolder​(String oldPath,
                                      String newPath)
        参数:
        oldPath - 准备拷贝的目录
        newPath - 指定绝对路径的新目录
      • moveFile

        public static void moveFile​(String oldPath,
                                    String newPath,
                                    boolean deleteOldFile)
        参数:
        oldPath -
        newPath -
        deleteOldFile -
      • moveFolder

        public static void moveFolder​(String oldPath,
                                      String newPath)
        参数:
        oldPath -
        newPath -
      • rename

        public static int rename​(Object fileName,
                                 String distFile)
        参数:
        fileName -
        distFile -
      • getFileMessageDigest

        public static String getFileMessageDigest​(String fileName,
                                                  String digestType)
        参数:
        fileName -
        digestType - :like MD5
        返回:
      • linkPath

        public static String linkPath​(String topPath,
                                      String lowPath)
        参数:
        topPath -
        lowPath -
        返回:
      • formatPath

        public static String formatPath​(String path)
        参数:
        path -
        返回:
      • getFile

        public static File getFile​(String fileName)
        参数:
        fileName -
        返回:
      • isPackage

        public static boolean isPackage​(String file)
        参数:
        file -
        返回:
      • appendFileByStream

        public static void appendFileByStream​(Object fileName,
                                              String content)
        参数:
        fileName -
        content -
      • appendFileByWriter

        public static void appendFileByWriter​(Object fileName,
                                              String content)
        参数:
        fileName -
        content -
      • appendFileByRandomAccess

        public static void appendFileByRandomAccess​(Object fileName,
                                                    String content)
        参数:
        fileName - 文件名
        content - 追加的内容
      • getParentPath

        public static String getParentPath​(String fileName)
        参数:
        fileName -
        返回:
      • skipPath

        public static String skipPath​(String basePath,
                                      String skipFile)
        参数:
        basePath -
        skipFile -
        返回: