LocalFileSystem extends FileSystem<LocalResourceId> { @Override protected ReadableByteChannel open(LocalResourceId resourceId) throws IOException { LOG.debug("opening file {}", resourceId); @SuppressWarnings("resource") FileInputStream inputStream = new FileInputStream(resourceId.getPath().toFile()); return inputStream.getChannel(); } LocalFileSystem();   }
@Test public void testReadWithExistingFile() throws Exception { String expected = "my test string"; File existingFile = temporaryFolder.newFile(); Files.write(expected, existingFile, StandardCharsets.UTF_8); String data; try (Reader reader = Channels.newReader( localFileSystem.open( LocalResourceId.fromPath(existingFile.toPath(), false )), StandardCharsets.UTF_8.name())) { data = new LineReader(reader).readLine(); } assertEquals(expected, data); }
@Test public void testReadNonExistentFile() throws Exception { thrown.expect(FileNotFoundException.class); localFileSystem .open( LocalResourceId.fromPath( temporaryFolder.getRoot().toPath().resolve("non-existent-file.txt"), false )) .close(); }