public class Utils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static TypeAwareByteSource |
getFile(java.io.File file)
Locates and reads a file either by a direct path or by a relative path in classpath.
|
static byte[] |
readFileToBytes(java.io.File file)
Reads a
File into an array of bytes. |
static byte[] |
readInputStreamToBytes(java.io.InputStream is)
Reads an
InputStream into an array of bytes. |
static byte[] |
readInputStreamToBytes(java.io.InputStream is,
int bufferSize)
Reads an
InputStream into an array of bytes. |
static java.lang.String |
readInputStreamToString(java.io.InputStream is)
Reads an
InputStream into a String. |
@Nonnull
public static java.lang.String readInputStreamToString(@Nonnull
java.io.InputStream is)
throws java.io.IOException
InputStream into a String. Uses UTF-8 encoding and 10 kilobytes buffer by
default.is - a stream to read fromjava.io.IOException - in case of a read errorpublic static byte[] readInputStreamToBytes(@Nonnull
java.io.InputStream is)
throws java.io.IOException
InputStream into an array of bytes. Uses 10 kilobytes buffer by default.is - a stream to read fromjava.io.IOException - in case of a read errorpublic static byte[] readInputStreamToBytes(@Nonnull
java.io.InputStream is,
int bufferSize)
throws java.io.IOException
InputStream into an array of bytes.is - a stream to read frombufferSize - size of read buffer in bytesjava.io.IOException - in case of a read errorpublic static byte[] readFileToBytes(@Nonnull
java.io.File file)
throws java.io.IOException
File into an array of bytes.file - a file to readjava.io.IOException - in case of a read error, or a file not foundpublic static TypeAwareByteSource getFile(@Nonnull java.io.File file) throws java.io.IOException
file - a file to locate and readjava.io.IOException - in case of a read error, or a file not found