Example usage for javax.annotation.processing Filer getResource

List of usage examples for javax.annotation.processing Filer getResource

Introduction

In this page you can find the example usage for javax.annotation.processing Filer getResource.

Prototype

FileObject getResource(JavaFileManager.Location location, CharSequence moduleAndPkg, CharSequence relativeName)
        throws IOException;

Source Link

Document

Returns an object for reading an existing resource.

Usage

From source file:cop.raml.processor.RestProcessor.java

@NotNull
private static Config getConfig() {
    Filer filter = ThreadLocalContext.getProcessingEnv().getFiler();

    if (filter == null)
        return Config.NULL;

    try (InputStream in = filter.getResource(StandardLocation.CLASS_OUTPUT, "", Config.YAML)
            .openInputStream()) {//from   ww  w  . j  av a  2s. c o  m
        return Config.builder().parse(IOUtils.toString(in, StandardCharsets.UTF_8)).build();
    } catch (Exception e) {
        ThreadLocalContext.getMessager().printMessage(ERROR,
                String.format("Cannot read YAML config: '%s'", e.getMessage()));
        return Config.NULL;
    }
}