public byte [ ] read ( ) throws IOException { Closer closer = Closer . create ( ) ; try { InputStream in = closer . register ( openStream ( ) ) ; Optional < Long > size = sizeIfKnown ( ) ; return size . isPresent ( ) ? ByteStreams . toByteArray ( in , size . get ( ) ) : ByteStreams . toByteArray ( in ) ; } catch ( Throwable e ) { throw closer . rethrow ( e ) ; } finally { closer . close ( ) ; } }
Reads the full contents of this byte source as a byte array .