Example usage for javax.tools JavaFileObject openReader

List of usage examples for javax.tools JavaFileObject openReader

Introduction

In this page you can find the example usage for javax.tools JavaFileObject openReader.

Prototype

Reader openReader(boolean ignoreEncodingErrors) throws IOException;

Source Link

Document

Returns a reader for this object.

Usage

From source file:dz.jtsgen.processor.helper.ReferenceHelper.java

public static void assertEquals(JavaFileObject testeeFile, String referenceFile) throws IOException {
    String testee = IOUtils.toString(testeeFile.openReader(true));
    String reference = IOUtils.toString(createReferenceStreamFor(referenceFile), Charset.forName("UTF-8"));
    Assert.assertEquals(reference, testee);
}

From source file:dz.jtsgen.processor.helper.OutputHelper.java

public static List<String> findSourceLine(Compilation c, String packageName, String fileName, Pattern pattern)
        throws IOException {
    Assert.assertTrue(c.generatedFile(StandardLocation.SOURCE_OUTPUT, packageName, fileName).isPresent());
    JavaFileObject jfo = c.generatedFile(StandardLocation.SOURCE_OUTPUT, packageName, fileName).get();
    try (Reader r = jfo.openReader(false)) {
        return IOUtils.readLines(r).stream().filter((x) -> pattern.matcher(x).find())
                .collect(Collectors.toList());
    }//from   ww  w.ja  v a  2  s .  c o  m
}