@Test public void testRead() throws Exception { LocalFileReader reader = new LocalFileReader(tempDirectory1, tempDirectory2); CharStream a = reader.read("1.proto"); CharStream b = reader.read("2.proto"); CharStream c = reader.read("3.proto"); assertNotNull(a); assertNotNull(b); assertNull(c); assertEquals("1", a.getText(Interval.of(0, 1))); assertEquals("2", b.getText(Interval.of(0, 1))); }
@Nullable @Override public CharStream read(String name) { for (Path prefix : pathList) { Path path = prefix.resolve(name); if (Files.isRegularFile(path)) { try { byte[] bytes = Files.readAllBytes(path); String result = new String(bytes, StandardCharsets.UTF_8); return CharStreams.fromString(result); } catch (IOException e) { LOGGER.trace("Could not read {}", path, e); } } } return null; }
LocalFileReader implements FileReader { @Nullable @Override public CharStream read(String name) { for (Path prefix : pathList) { Path path = prefix.resolve(name); if (Files.isRegularFile(path)) { try { byte[] bytes = Files.readAllBytes(path); String result = new String(bytes, StandardCharsets.UTF_8); return CharStreams.fromString(result); } catch (IOException e) { LOGGER.trace("Could not read {}", path, e); } } } return null; } }
LocalFileReader implements FileReader { @Nullable @Override public CharStream read(String name) { for (Path prefix : pathList) { Path path = prefix.resolve(name); if (Files.isRegularFile(path)) { try { byte[] bytes = Files.readAllBytes(path); String result = new String(bytes, StandardCharsets.UTF_8); return CharStreams.fromString(result); } catch (IOException e) { LOGGER.trace("Could not read {}", path, e); } } } return null; } LocalFileReader(Path... paths);  LocalFileReader(List<Path> paths); }
LocalFileReader implements FileReader { @Nullable @Override public CharStream read(String name) { for (Path prefix : pathList) { Path path = prefix.resolve(name); if (Files.isRegularFile(path)) { try { byte[] bytes = Files.readAllBytes(path); String result = new String(bytes, StandardCharsets.UTF_8); return CharStreams.fromString(result); } catch (IOException e) { LOGGER.trace("Could not read {}", path, e); } } } return null; } LocalFileReader(Path... paths);  LocalFileReader(List<Path> paths); @Nullable @Override CharStream read(String name); }
LocalFileReader implements FileReader { @Nullable @Override public CharStream read(String name) { for (Path prefix : pathList) { Path path = prefix.resolve(name); if (Files.isRegularFile(path)) { try { byte[] bytes = Files.readAllBytes(path); String result = new String(bytes, StandardCharsets.UTF_8); return CharStreams.fromString(result); } catch (IOException e) { LOGGER.trace("Could not read {}", path, e); } } } return null; } LocalFileReader(Path... paths);  LocalFileReader(List<Path> paths); @Nullable @Override CharStream read(String name);  }