@Override public FileObject getFileForOutput(Location location, String packageName, String relativeName, final FileObject sibling) throws IOException { FileObject fileObject = super.getFileForOutput(location, packageName, relativeName, sibling); return new ForwardingFileObject<FileObject>(fileObject) { @Override public OutputStream openOutputStream() throws IOException { record(sibling != null ? FileObjects.toFile(sibling) : null, FileObjects.toFile(fileObject)); return new IncrementalFileOutputStream(FileObjects.toFile(this)); } @Override public Writer openWriter() throws IOException { return encoding != null ? new OutputStreamWriter(openOutputStream(), encoding) : new OutputStreamWriter(openOutputStream()); } }; }