Exemplo n.º 1
0
  public Writer openSource(JPackage pkg, String fileName) throws IOException {
    String name;
    if (pkg.isUnnamed()) name = fileName;
    else name = pkg.name() + '.' + fileName;

    name = name.substring(0, name.length() - 5); // strip ".java"

    return filer.createSourceFile(name);
  }
Exemplo n.º 2
0
 public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
   Filer.Location loc;
   if (fileName.endsWith(".java")) {
     // APT doesn't do the proper Unicode escaping on Java source files,
     // so we can't rely on Filer.createSourceFile.
     loc = SOURCE_TREE;
   } else {
     // put non-Java files directly to the output folder
     loc = CLASS_TREE;
   }
   return filer.createBinaryFile(loc, pkg.name(), new File(fileName));
 }