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


Java JavaFileObject.delete方法代码示例

本文整理汇总了Java中javax.tools.JavaFileObject.delete方法的典型用法代码示例。如果您正苦于以下问题:Java JavaFileObject.delete方法的具体用法?Java JavaFileObject.delete怎么用?Java JavaFileObject.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.tools.JavaFileObject的用法示例。


在下文中一共展示了JavaFileObject.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeClass

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
 * Emit a class file for a given class.
 *
 * @param c The class from which a class file is generated.
 */
public JavaFileObject writeClass(ClassSymbol c)
        throws IOException, PoolOverflow, StringOverflow {
    JavaFileObject outFile
            = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
            c.flatname.toString(),
            JavaFileObject.Kind.CLASS,
            c.sourcefile);
    OutputStream out = outFile.openOutputStream();
    try {
        writeClassFile(out, c);
        if (verbose)
            log.printVerbose("wrote.file", outFile);
        out.close();
        out = null;
    } finally {
        if (out != null) {
            // if we are propogating an exception, delete the file
            out.close();
            outFile.delete();
            outFile = null;
        }
    }
    return outFile; // may be null if write failed
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:30,代码来源:ClassWriter.java

示例2: writeClass

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/** Emit a class file for a given class.
 *  @param c      The class from which a class file is generated.
 */
public JavaFileObject writeClass(ClassSymbol c)
    throws IOException, PoolOverflow, StringOverflow
{
    JavaFileObject outFile
        = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
                                           c.flatname.toString(),
                                           JavaFileObject.Kind.CLASS,
                                           c.sourcefile);
    OutputStream out = outFile.openOutputStream();
    try {
        writeClassFile(out, c);
        if (verbose)
            log.printVerbose("wrote.file", outFile);
        out.close();
        out = null;
    } finally {
        if (out != null) {
            // if we are propagating an exception, delete the file
            out.close();
            outFile.delete();
            outFile = null;
        }
    }
    return outFile; // may be null if write failed
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:ClassWriter.java

示例3: writeJavaFile

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private boolean writeJavaFile(JavaFile javaFile) {
    StringBuilder builder = new StringBuilder();

    JavaFileObject filerSourceFile = null;

    try {
        builder.append(LICENSE_HEADER);
        javaFile.writeTo(builder);

        String fileName = javaFile.packageName.isEmpty() ? javaFile.typeSpec.name : javaFile.packageName + "." + javaFile.typeSpec.name;
        List<Element> originatingElements = javaFile.typeSpec.originatingElements;
        filerSourceFile = mFiler.createSourceFile(fileName, originatingElements.toArray(new Element[originatingElements.size()]));

        try (Writer writer = filerSourceFile.openWriter()) {
            writer.write(builder.toString());
        }
        return true;

    } catch (Exception e) {
        mMessager.printMessage(Diagnostic.Kind.ERROR, "Couldn't generate classes " + javaFile.packageName + '.' + javaFile.typeSpec.name);
        e.printStackTrace();

        if (filerSourceFile != null) {
            filerSourceFile.delete();
        }

        return false;
    }
}
 
开发者ID:evernote,项目名称:android-state,代码行数:30,代码来源:StateProcessor.java

示例4: writeClass

import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/** Emit a class file for a given class.
 *  @param c      The class from which a class file is generated.
 */
public JavaFileObject writeClass(ClassSymbol c)
    throws IOException, PoolOverflow, StringOverflow
{
    String name = (c.owner.kind == MDL ? c.name : c.flatname).toString();
    Location outLocn;
    if (multiModuleMode) {
        ModuleSymbol msym = c.owner.kind == MDL ? (ModuleSymbol) c.owner : c.packge().modle;
        outLocn = fileManager.getLocationForModule(CLASS_OUTPUT, msym.name.toString());
    } else {
        outLocn = CLASS_OUTPUT;
    }
    JavaFileObject outFile
        = fileManager.getJavaFileForOutput(outLocn,
                                           name,
                                           JavaFileObject.Kind.CLASS,
                                           c.sourcefile);
    OutputStream out = outFile.openOutputStream();
    try {
        writeClassFile(out, c);
        if (verbose)
            log.printVerbose("wrote.file", outFile);
        out.close();
        out = null;
    } finally {
        if (out != null) {
            // if we are propagating an exception, delete the file
            out.close();
            outFile.delete();
            outFile = null;
        }
    }
    return outFile; // may be null if write failed
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:ClassWriter.java


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