Google Guavaには、InputSuppliersを作成するためのファクトリメソッドがいくつかありますbyte[]
。
ByteStreams.newInputStreamSupplier(bytes);
またはからFile
:
Files.newInputStreamSupplier(file);
InputSupplier
与えられたものを作成する同様の方法はありInputStream
ますか?
つまり、匿名クラスよりも簡潔な方法です。
new InputSupplier<InputStream>() {
public InputStream getInput() throws IOException {
return inputStream;
}
};
Files.copy(...)
背景:egまたは。でInputStreamsを使用したいと思いByteStreams.equal(...)
ます。