ByteSourceUtil

Utility class that can construct ByteSource instances. This is slightly nicer than needing to know the {@code ByteSource} implementation class to use.

@since 1.2

Members

Static functions

bytes
ByteSource bytes(byte[] bytes)

Returns a new {@code ByteSource} instance representing the specified byte array.

bytes
ByteSource bytes(char[] chars)

Returns a new {@code ByteSource} instance representing the specified character array's bytes. The byte array is obtained assuming {@code UTF-8} encoding.

bytes
ByteSource bytes(string string)

Returns a new {@code ByteSource} instance representing the specified string's bytes. The byte array is obtained assuming {@code UTF-8} encoding.

bytes
ByteSource bytes(ByteSource source)

Returns a new {@code ByteSource} instance representing the specified ByteSource.

bytes
ByteSource bytes(Object source)

Returns a {@code ByteSource} instance representing the specified byte source argument. If the argument <em>cannot</em> be easily converted to bytes (as is indicated by the {@link #isCompatible(Object)} JavaDoc), this method will throw an {@link IllegalArgumentException}.

isCompatible
bool isCompatible(Object source)

Returns {@code true} if the specified object can be easily represented as a {@code ByteSource} using the {@link ByteSourceUtil}'s default heuristics, {@code false} otherwise. <p/> This implementation merely returns {@link SimpleByteSource}.{@link SimpleByteSource#isCompatible(Object) isCompatible(source)}.

Meta