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


Java FileObject.delete方法代码示例

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


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

示例1: write

import javax.tools.FileObject; //导入方法依赖的package包/类
/** Emit a class file for a given class.
 *  @param c      The class from which a class file is generated.
 */
public FileObject write(ClassSymbol c)
    throws IOException
{
    String className = c.flatName().toString();
    FileObject outFile
        = fileManager.getFileForOutput(StandardLocation.NATIVE_HEADER_OUTPUT,
            "", className.replaceAll("[.$]", "_") + ".h", null);
    Writer out = outFile.openWriter();
    try {
        write(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:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:JNIWriter.java

示例2: doWithOriAndPrintWriter

import javax.tools.FileObject; //导入方法依赖的package包/类
public static void doWithOriAndPrintWriter(Filer filer, JavaFileManager.Location location, String relativePath, String filename, BiConsumer<String, PrintWriter> consumer){
    try {
        FileObject resource = filer.getResource(location, relativePath, filename);
        String data;
        try{
            CharSequence cs = resource.getCharContent(false);
            data = cs.toString();
            resource.delete();
        }catch (FileNotFoundException ignored){
            data = "";
        }
        resource = filer.createResource(location, relativePath, filename);

        try(OutputStream outputStream = resource.openOutputStream()){
            consumer.accept(data,new PrintWriter(outputStream));
        }
    } catch (IOException e) {
        note("do with resource file failed"+relativePath+filename+" Exception: " + e.toString());
    }
}
 
开发者ID:frankelau,项目名称:pndao,代码行数:21,代码来源:ResourceHelper.java

示例3: write

import javax.tools.FileObject; //导入方法依赖的package包/类
/** Emit a class file for a given class.
 *  @param c      The class from which a class file is generated.
 */
public FileObject write(ClassSymbol c) throws IOException {
    String className = c.flatName().toString();
    Location outLocn;
    if (multiModuleMode) {
        ModuleSymbol msym = c.owner.kind == MDL ? (ModuleSymbol) c.owner : c.packge().modle;
        outLocn = fileManager.getLocationForModule(StandardLocation.NATIVE_HEADER_OUTPUT, msym.name.toString());
    } else {
        outLocn = StandardLocation.NATIVE_HEADER_OUTPUT;
    }
    FileObject outFile
        = fileManager.getFileForOutput(outLocn,
            "", className.replaceAll("[.$]", "_") + ".h", null);
    PrintWriter out = new PrintWriter(outFile.openWriter());
    try {
        write(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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:JNIWriter.java


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