程序包 org.xmeta.util

类 UtilFile


  • public class UtilFile
    extends Object
    文件工具类。
    作者:
    zyx
    • 构造器详细资料

      • UtilFile

        public UtilFile()
    • 方法详细资料

      • delete

        public static void delete​(File afile)
        递归删除一个文件或目录。
        参数:
        afile - 要删除的文件或目录
      • copyFile

        public static void copyFile​(File src,
                                    File target,
                                    FileCopyMonitor monitor)
                             throws IOException
        拷贝文件。
        参数:
        src - 源文件
        target - 目标文件
        monitor - 监控器
        抛出:
        IOException - IO异常
      • toXWorkerFilePath

        public static String toXWorkerFilePath​(String fileName)
        把一个正常的文件路径转化成XWorker表示下的文件路径。
        参数:
        fileName - 文件名
        返回:
        字符串
      • getFilePath

        public static String getFilePath​(String fileName)
        获取文件路径,符合XWorker文件路径规则的。
        参数:
        fileName - 文件名
        返回:
        路径
      • getFileOrInputStream

        public static Object getFileOrInputStream​(String path,
                                                  ActionContext actionContext)
        从路径获取文件或输入流。
        参数:
        path - 路径
        actionContext - 变量上下文
        返回:
        对象
      • getThingPathByFile

        public static String getThingPathByFile​(File file)
                                         throws IOException
        如果目标文件是一个模型文件,那么返回它的事物路径。 在操作中还会通过.dmlprj和xworker.properties文件自动查找它所属的项目,如果找不到项目,那么把模型事物所在的目录作为它的项目, 如果项目存在那么还会加入到XWorker的事物管理器中。
        参数:
        file - 模型文件
        返回:
        模型的路径,如果文件不是模型,那么返回null
        抛出:
        IOException
      • getThingPath

        public static String getThingPath​(File projectDir,
                                          File thingFile)
        通过项目路径和事物文件返回事物的真正路径。
        参数:
        projectDir - 项目目录
        thingFile - 事物文件
        返回:
        事物路径
      • getThingManagerNameByDir

        public static String getThingManagerNameByDir​(File dir)
                                               throws IOException
        从一个dir中获取事物管理器的名称。
        参数:
        dir -
        返回:
        抛出:
        IOException
      • isParent

        public static boolean isParent​(File parentFile,
                                       File childFile)
                                throws IOException
        判断childFile是否是parentFile的一个子文件,包括更深的子目录等。
        参数:
        parentFile -
        childFile -
        返回:
        抛出:
        IOException