public static final class ByteSource.Util extends Object
ByteSource implementation class to use.
| Constructor and Description |
|---|
Util()
|
| Modifier and Type | Method and Description |
|---|---|
static ByteSource |
bytes(byte[] bytes)
Returns a new
ByteSource instance representing the specified byte array.
|
static ByteSource |
bytes(ByteSource
Returns a new
ByteSource instance representing the specified ByteSource.
|
static ByteSource |
bytes(char[] chars)
Returns a new
ByteSource instance representing the specified character array's bytes.
|
static ByteSource |
bytes(File
Returns a new
ByteSource instance representing the specified File's bytes.
|
static ByteSource |
bytes(InputStream
Returns a new
ByteSource instance representing the specified InputStream's bytes.
|
static ByteSource |
bytes(Object
Returns a
ByteSource instance representing the specified byte source argument.
|
static ByteSource |
bytes(String
Returns a new
ByteSource instance representing the specified string's bytes.
|
static boolean |
isCompatible(Object
Returns
true if the specified object can be easily represented as a
ByteSource using the
ByteSource.Util's default heuristics,
false otherwise.
|
public static ByteSourcebytes(byte[] bytes)
ByteSource instance representing the specified byte array.
bytes - the bytes to represent as a
ByteSource instance.
ByteSource instance representing the specified byte array.
public static ByteSourcebytes(char[] chars)
ByteSource instance representing the specified character array's bytes. The byte array is obtained assuming
UTF-8 encoding.
chars - the character array to represent as a
ByteSource instance.
ByteSource instance representing the specified character array's bytes.
public static ByteSourcebytes(String string)
ByteSource instance representing the specified string's bytes. The byte array is obtained assuming
UTF-8 encoding.
string - the string to represent as a
ByteSource instance.
ByteSource instance representing the specified string's bytes.
public static ByteSourcebytes(ByteSource source)
ByteSource instance representing the specified ByteSource.
source - the ByteSource to represent as a new
ByteSource instance.
ByteSource instance representing the specified ByteSource.
public static ByteSourcebytes(File file)
ByteSource instance representing the specified File's bytes.
file - the file to represent as a
ByteSource instance.
ByteSource instance representing the specified File's bytes.
public static ByteSourcebytes(InputStream stream)
ByteSource instance representing the specified InputStream's bytes.
stream - the InputStream to represent as a
ByteSource instance.
ByteSource instance representing the specified InputStream's bytes.
public static boolean isCompatible(Objectsource)
true if the specified object can be easily represented as a
ByteSource using the
ByteSource.Util's default heuristics,
false otherwise.
This implementation merely returns
SimpleByteSource.
isCompatible(source).
source - the object to test to see if it can be easily converted to ByteSource instances using default heuristics.
true if the specified object can be easily represented as a
ByteSource using the
ByteSource.Util's default heuristics,
false otherwise.
public static ByteSourcebytes(Object source) throws IllegalArgumentException
ByteSource instance representing the specified byte source argument. If the argument
cannot be easily converted to bytes (as is indicated by the
isCompatible(Object) JavaDoc), this method will throw an
IllegalArgumentException.
source - the byte-backed instance that should be represented as a
ByteSource instance.
ByteSource instance representing the specified byte source argument.
IllegalArgumentException - if the argument
cannot be easily converted to bytes (as indicated by the
isCompatible(Object) JavaDoc)