本文整理汇总了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
}
示例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());
}
}
示例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
}