Can you write this with Guava ```ByteStreams.limit```?  This avoids the extra copy in memory.