public class JavaSourceFileObject extends SimpleJavaFileObject
JavaFileObject.Kindkind, uri| Modifier | Constructor and Description |
|---|---|
protected |
JavaSourceFileObject(String name,
InputStream inputStream)
构造,支持流中读取源码(例如zip或网络等)
|
protected |
JavaSourceFileObject(String className,
String code,
Charset charset)
构造,支持String类型的源码
|
protected |
JavaSourceFileObject(URI uri)
构造,支持File等路径类型的源码
|
| Modifier and Type | Method and Description |
|---|---|
CharSequence |
getCharContent(boolean ignoreEncodingErrors)
获得类源码
编译器编辑源码前,会通过此方法获取类的源码
|
InputStream |
openInputStream()
获得类源码的输入流
|
delete, getAccessLevel, getKind, getLastModified, getName, getNestingKind, isNameCompatible, openOutputStream, openReader, openWriter, toString, toUriprotected JavaSourceFileObject(URI uri)
uri - 需要编译的文件uriprotected JavaSourceFileObject(String className, String code, Charset charset)
className - 需要编译的类名code - 需要编译的类源码charset - 编码protected JavaSourceFileObject(String name, InputStream inputStream)
name - 需要编译的文件名inputStream - 输入流public InputStream openInputStream() throws IOException
openInputStream in interface FileObjectopenInputStream in class SimpleJavaFileObjectIOException - IO 异常public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException
getCharContent in interface FileObjectgetCharContent in class SimpleJavaFileObjectignoreEncodingErrors - 是否忽略编码错误IOException - IO异常Copyright © 2022. All rights reserved.