public class IOUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.io.InputStream |
getInputStreamFromURLOrClasspathOrFileSystem(java.lang.String textFileOrUrl)
Locates this file either using the given URL, or in the CLASSPATH, or in the file system
The CLASSPATH takes priority over the file system!
This stream is buffered and gunzipped (if necessary).
|
static java.io.BufferedReader |
readerFromString(java.lang.String textFileOrUrl)
Open a BufferedReader to a file, class path entry or URL specified by a String name.
|
static java.io.BufferedReader |
readerFromString(java.lang.String textFileOrUrl,
java.lang.String encoding)
Open a BufferedReader to a file or URL specified by a String name.
|
static java.lang.String |
slurpReader(java.io.Reader reader)
Returns all the text from the given Reader.
|
static void |
writeStringToFile(java.lang.String contents,
java.lang.String path,
java.lang.String encoding)
Writes a string to a file.
|
public static java.io.BufferedReader readerFromString(java.lang.String textFileOrUrl)
throws java.io.IOException
textFileOrUrl - What to read fromjava.io.IOException - If there is an I/O problempublic static java.io.BufferedReader readerFromString(java.lang.String textFileOrUrl,
java.lang.String encoding)
throws java.io.IOException
textFileOrUrl - What to read fromencoding - CharSet encoding. Maybe be null, in which case the
platform default encoding is usedjava.io.IOException - If there is an I/O problempublic static java.lang.String slurpReader(java.io.Reader reader)
public static java.io.InputStream getInputStreamFromURLOrClasspathOrFileSystem(java.lang.String textFileOrUrl)
throws java.io.IOException,
java.lang.NullPointerException
textFileOrUrl - The String specifying the URL/resource/file to loadjava.io.IOException - On any IO errorjava.lang.NullPointerException - Input parameter is nullpublic static void writeStringToFile(java.lang.String contents,
java.lang.String path,
java.lang.String encoding)
throws java.io.IOException
contents - The string to writepath - The file pathencoding - The encoding to encode injava.io.IOException - In case of failure