Simple question: Is there a class or interface that encapulates the getting of a Reader or an InputStream?
What I want is to be able to for example read from a File twice, or a URL twice, and encapulate / abstract the creation of the Reader or InputStream as much as possible
In guava, there is a
InputSupplierinterface, that seems to do what you’re looking for.Guava also has factories that create inputSuppliers, like
ResourcesorFilesclass – check out thenewInputStreamSuppliermethods in those classes to see how it works.