Is there a concise way to create an InputSupplier for an InputStream in Google Guava?
- by Fabian Steeg
There are a few factory methods in Google Guava to create InputSuppliers, e.g. from a byte[]:
ByteStreams.newInputStreamSupplier(bytes);
Or from a File:
Files.newInputStreamSupplier(file);
Is there a similar way to to create an InputSupplier for a given InputStream?
That is, a way that's more concise than an anonymous class:
new InputSupplier<InputStream>() {
public InputStream getInput() throws IOException {
return inputStream;
}
};
Background: I'd like to use InputStreams with e.g. Files.copy(...) or ByteStreams.equal(...).