@Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
        if (baos == null) {
            throw new FileNotFoundException(name);
        }
        return new String(baos.toByteArray(), StandardCharsets.UTF_8);
    }
MemJavaFileObject defines an in memory compiled Java file

@author tiwe
querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/MemJavaFileObject.java