in src/it/jdk16-annotation/src/main/java/com/mycompany/jdk16annotation/ServiceProviderProcessor.java [62:88]
private void writeServices() {
try {
FileObject out = processingEnv
.getFiler()
.createResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/one", new Element[0]);
OutputStream os = out.openOutputStream();
OutputStream os2 = processingEnv
.getFiler()
.createSourceFile("org.Milos", new Element[0])
.openOutputStream();
OutputStreamWriter osr = new OutputStreamWriter(os2);
try {
PrintWriter w = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));
w.write("test");
w.flush();
String clazz = "package org;\n class Milos {}";
osr.write(clazz.toCharArray());
osr.flush();
} finally {
osr.close();
os.close();
}
} catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, "Failed to write to one: " + x.toString());
}
}