类 MyUtils

java.lang.Object
com.gdxsoft.easyweb.resources.MyUtils

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

    • MyUtils

      public MyUtils()
  • 方法详细资料

    • md5

      public static String md5(byte[] buf)
    • hex

      public static String hex(byte[] digest)
    • md5

      public static String md5(String str)
    • delete

      public static boolean delete(String name)
      Delete a file
      参数:
      name - The file path and name
      返回:
      result
    • getFileExt

      public static String getFileExt(String name)
      Get the extension form the file name
      参数:
      name - the file name
      返回:
      the extension
    • getFileNoExt

      public static String getFileNoExt(String name)
      Get the file name without extension
      参数:
      name - the file name
      返回:
      the file name without extension
    • changeFileExt

      public static String changeFileExt(String name, String newExt)
      Change the file extension
      参数:
      name - the file's name and path
      newExt - new extension
      返回:
      new file name and path
    • readFileBytes

      public static byte[] readFileBytes(String path) throws IOException
      Read the binary contents of the file
      参数:
      path - the file name and path
      返回:
      binary contents
      抛出:
      IOException
    • readFileText

      public static String readFileText(String filePath) throws IOException
      Read the file contents(UTF8) from file or resource
      参数:
      filePath - the file name and path
      返回:
      the file contents (UTF8)
      抛出:
      IOException
    • readZipBytes

      public static byte[] readZipBytes(String zipFilePath, String innerFileName) throws IOException
      Read the zip/jar file binary (UTF8)
      参数:
      zipFilePath - the zip or jar file
      innerFileName - zip or jar inner path and name
      返回:
      the content of the file in the zip/jar
      抛出:
      IOException
    • getZipList

      public static List<String> getZipList(String zipFilePath) throws IOException
      Get the zip/jar file list
      参数:
      zipFilePath - the zip or jar file
      返回:
      The zip file list
      抛出:
      IOException
    • readZipText

      public static String readZipText(String zipFilePath, String innerFileName) throws IOException
      抛出:
      IOException
    • copyFile

      public static void copyFile(String fileFrom, String fileTo) throws IOException
      Copy file
      参数:
      fileFrom - from
      fileTo - to
      抛出:
      IOException
    • zipFile

      public static String zipFile(String filePath) throws IOException
      Compress the file with ZIP
      参数:
      filePath - the file name and path
      返回:
      the ZIP file name and path
      抛出:
      IOException
    • zipPath

      public static String zipPath(String path) throws IOException
      Compress the path with ZIP, exclude sub directories
      参数:
      path - the path
      返回:
      zipFileName the ZIP file name and path
      抛出:
      IOException
    • zipFiles

      public static void zipFiles(String[] files, String zipFileName) throws IOException
      Compress the files with ZIP
      参数:
      files - the file path and name array
      zipFileName - the ZIP file path and name
      抛出:
      IOException
    • zipPaths

      public static void zipPaths(String pathRoot, String zipFileName) throws IOException
      Compress all files in the root directory, including sub directories
      参数:
      pathRoot - the root directory
      zipFileName - the compressed ZIP file path and name
      抛出:
      IOException
    • zipFiles

      public static void zipFiles(File[] files, String zipFileName) throws IOException
      Compress files
      参数:
      files - the files array
      zipFileName - the compressed ZIP file path and name
      抛出:
      IOException
    • unZipFile

      public static List<String> unZipFile(String zipFilePath) throws IOException
      Unzip files to the zipFilePath.xxx.unzip dir
      参数:
      zipFilePath - the zip file path and name
      返回:
      list of unziped files
      抛出:
      IOException
    • unZipFile

      public static List<String> unZipFile(String zipFilePath, String targetPath) throws IOException
      Unzip files to the target dir
      参数:
      zipFilePath - the zip file path and name
      targetPath - the unziped dir
      返回:
      list of unziped files
      抛出:
      IOException
    • createHashTextFile

      public static String createHashTextFile(String content, String ext, String path, boolean isOverWrite) throws Exception
      Create a hash file based on the content
      参数:
      content - the content
      ext - the hash file extension
      path - the directory where the hash file is saved
      isOverWrite - whether to overwrite the hash file
      返回:
      the hash file name, exclude path
      抛出:
      Exception
    • createNewTextFile

      public static void createNewTextFile(String fileName, String content) throws IOException
      Create a new text file
      参数:
      fileName - the saved file name and directory
      content - the saved text content (UTF8)
      抛出:
      IOException
    • createMd5File

      public static String createMd5File(byte[] bytes, String md5, String ext, String path, boolean isOverWrite) throws Exception
      Create a binary file based on the MD5 of the binary content, and the saved file name is MD5 + extension
      参数:
      bytes - The binary content
      md5 - The md5
      ext - The saved file extension
      path - The saved directory
      isOverWrite - Whether to overwrite
      返回:
      The saved file name (MD5 + extension), exclude directory
      抛出:
      Exception
    • createBinaryFile

      public static void createBinaryFile(String path, byte[] bytes, boolean isOverWrite) throws Exception
      Create a binary file
      参数:
      path - The file name and path to be created
      bytes - The saved binary
      isOverWrite - Whether to overwrite
      抛出:
      Exception
    • buildPaths

      public static boolean buildPaths(String path)
      Create the paths
      参数:
      path - the path
      返回:
      result