当前位置: 首页>>代码示例>>Java>>正文


Java ZipFileObject类代码示例

本文整理汇总了Java中com.sun.tools.javac.file.ZipArchive.ZipFileObject的典型用法代码示例。如果您正苦于以下问题:Java ZipFileObject类的具体用法?Java ZipFileObject怎么用?Java ZipFileObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZipFileObject类属于com.sun.tools.javac.file.ZipArchive包,在下文中一共展示了ZipFileObject类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.sun.tools.javac.file.ZipArchive.ZipFileObject; //导入依赖的package包/类
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:48,代码来源:T6705935.java


注:本文中的com.sun.tools.javac.file.ZipArchive.ZipFileObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。