public final class IoUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(java.io.InputStream in,
java.io.File dest)
Copies an input stream into a file.
|
static java.io.InputStream |
getRequestInputStream(javax.servlet.http.HttpServletRequest request)
Gets an uncompressed
InputStream for the request. |
static java.lang.String |
readFile(java.io.File file)
Reads the full content of a file.
|
static java.util.List<java.lang.String> |
readFiles(java.io.File directory,
java.io.FileFilter filter)
Reads and returns the content of all files under a directory that satisfy a filter.
|
static java.lang.String |
readRequestBody(javax.servlet.http.HttpServletRequest request)
Reads a possibly compressed request body.
|
static java.lang.String |
readResourceFile(java.lang.Class<?> c,
java.lang.String fileName)
Loads a text resource file for a class.
|
static java.lang.String |
readStream(java.io.InputStream is)
Reads the full content of a stream and returns it in a string.
|
public static java.lang.String readResourceFile(java.lang.Class<?> c,
java.lang.String fileName)
throws java.io.IOException
c - Class to load resource for.fileName - Path to resource file.java.io.IOExceptionpublic static void copy(java.io.InputStream in,
java.io.File dest)
throws java.io.IOException
in - Input stream to copy.dest - File to copy to.java.io.IOExceptionpublic static java.lang.String readFile(java.io.File file)
throws java.io.FileNotFoundException,
java.io.IOException
java.io.FileNotFoundExceptionjava.io.IOExceptionpublic static java.util.List<java.lang.String> readFiles(java.io.File directory,
java.io.FileFilter filter)
throws java.io.FileNotFoundException,
java.io.IOException
directory - Directory under which to read filesfilter - File filter used to pick which files to readjava.io.FileNotFoundExceptionjava.io.IOExceptionpublic static java.lang.String readStream(java.io.InputStream is)
throws java.io.IOException
java.io.IOExceptionpublic static java.io.InputStream getRequestInputStream(javax.servlet.http.HttpServletRequest request)
throws java.io.IOException
InputStream for the request. If the request specifies gzip
encoding, tries to wrap the request input stream in a GZIPInputStream. If the input
stream does not start with a gzip header, then a stream representing a plaintext request is
returned.java.io.IOExceptionpublic static java.lang.String readRequestBody(javax.servlet.http.HttpServletRequest request)
throws java.io.IOException
java.io.IOException