public final class JavaFileObjects extends Object
JavaFileObject instances.| Modifier and Type | Method and Description |
|---|---|
static JavaFileObject |
forResource(String resourceName)
Returns a
JavaFileObject for the class path resource with the given
resourceName. |
static JavaFileObject |
forResource(URL resourceUrl)
Returns a
JavaFileObject for the resource at the given URL. |
static JavaFileObject |
forSourceLines(String fullyQualifiedName,
Iterable<String> lines)
An overload of
#forSourceLines that takes an Iterable<String>. |
static JavaFileObject |
forSourceLines(String fullyQualifiedName,
String... lines)
Behaves exactly like
forSourceString(java.lang.String, java.lang.String), but joins lines so that multi-line source
strings may omit the newline characters. |
static JavaFileObject |
forSourceString(String fullyQualifiedName,
String source)
Creates a
JavaFileObject with a path corresponding to the fullyQualifiedName
containing the give source. |
public static JavaFileObject forSourceString(String fullyQualifiedName, String source)
JavaFileObject with a path corresponding to the fullyQualifiedName
containing the give source. The returned object will always be read-only and have the
JavaFileObject.Kind.SOURCE kind.
Note that this method makes no attempt to verify that the name matches the contents of the source and compilation errors may result if they do not match.
public static JavaFileObject forSourceLines(String fullyQualifiedName, String... lines)
forSourceString(java.lang.String, java.lang.String), but joins lines so that multi-line source
strings may omit the newline characters. For example:
JavaFileObjects.forSourceLines("example.HelloWorld",
"package example;",
"",
"final class HelloWorld {",
" void sayHello() {",
" System.out.println(\"hello!\");",
" }",
"}");
public static JavaFileObject forSourceLines(String fullyQualifiedName, Iterable<String> lines)
#forSourceLines that takes an Iterable<String>.public static JavaFileObject forResource(URL resourceUrl)
JavaFileObject for the resource at the given URL. The returned object
will always be read-only and the kind is inferred via
the JavaFileObject.Kind.extension.public static JavaFileObject forResource(String resourceName)
JavaFileObject for the class path resource with the given
resourceName. This method is equivalent to invoking
forResource(Resources.getResource(resourceName)).Copyright © 2013–2020. All rights reserved.