Is there a concise way to create an InputSupplier for an InputStream in Google Guava?

Posted by Fabian Steeg on Stack Overflow See other posts from Stack Overflow or by Fabian Steeg
Published on 2010-03-02T13:35:38Z Indexed on 2010/03/17 13:31 UTC
Read the original article Hit count: 230

Filed under:
|
|

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(...).

© Stack Overflow or respective owner

Related posts about java

Related posts about guava