From b41c4c2ab005687e252661ee7e8d508c9c0369a6 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 22 May 2014 10:43:57 -0700 Subject: [PATCH] Backport ByteSources.repeatingArrayByteSource --- core/src/main/java/org/jclouds/io/ByteSources.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/org/jclouds/io/ByteSources.java b/core/src/main/java/org/jclouds/io/ByteSources.java index 06fe135460..7055664195 100644 --- a/core/src/main/java/org/jclouds/io/ByteSources.java +++ b/core/src/main/java/org/jclouds/io/ByteSources.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.InputStream; import com.google.common.annotations.Beta; +import com.google.common.collect.Iterables; import com.google.common.io.ByteSource; /** @@ -48,4 +49,8 @@ public class ByteSources { }; } + /** Create an infinite-length ByteSource which repeats its input. */ + public static ByteSource repeatingArrayByteSource(final byte[] input) { + return ByteSource.concat(Iterables.cycle(ByteSource.wrap(input))); + } }