@Test public void test() throws Exception { Provider<InputStream> ip = new Provider<InputStream>() { @Override public InputStream open() throws IOException, InterruptedException { return new ByteArrayInputStream("Hello, world!".getBytes(CHARSET)); } @Override public void close() throws IOException { return; } }; closeables.add(ip); ReaderProvider rp = new ReaderProvider(ip, CHARSET); closeables.add(rp); Scanner s1 = new Scanner(rp.open()); closeables.add(s1); assertThat(s1.hasNextLine(), is(true)); assertThat(s1.nextLine(), is("Hello, world!")); assertThat(s1.hasNextLine(), is(false)); Scanner s2 = new Scanner(rp.open()); closeables.add(s2); assertThat(s2.hasNextLine(), is(true)); assertThat(s2.nextLine(), is("Hello, world!")); assertThat(s2.hasNextLine(), is(false)); }
@Override public Reader open() throws IOException, InterruptedException { return new InputStreamReader(streamProvider.open(), encoding); }
ReaderProvider implements Provider<Reader> { @Override public Reader open() throws IOException, InterruptedException { return new InputStreamReader(streamProvider.open(), encoding); } }
ReaderProvider implements Provider<Reader> { @Override public Reader open() throws IOException, InterruptedException { return new InputStreamReader(streamProvider.open(), encoding); } ReaderProvider(Provider<? extends InputStream> streamProvider, Charset encoding); }
ReaderProvider implements Provider<Reader> { @Override public Reader open() throws IOException, InterruptedException { return new InputStreamReader(streamProvider.open(), encoding); } ReaderProvider(Provider<? extends InputStream> streamProvider, Charset encoding); @Override Reader open(); @Override void close(); @Override String toString(); }
ReaderProvider implements Provider<Reader> { @Override public Reader open() throws IOException, InterruptedException { return new InputStreamReader(streamProvider.open(), encoding); } ReaderProvider(Provider<? extends InputStream> streamProvider, Charset encoding); @Override Reader open(); @Override void close(); @Override String toString();  }