【发布时间】:2010-03-02 13:35:38
【问题描述】:
Google Guava 中有一些工厂方法可以创建 InputSuppliers,例如来自byte[]:
ByteStreams.newInputStreamSupplier(bytes);
或来自File:
Files.newInputStreamSupplier(file);
是否有类似的方法可以为给定的InputStream 创建InputSupplier?
也就是说,一种比匿名类更简洁的方式:
new InputSupplier<InputStream>() {
public InputStream getInput() throws IOException {
return inputStream;
}
};
背景:我想使用 InputStreams,例如Files.copy(...) 或 ByteStreams.equal(...)。
【问题讨论】: