public class Lib
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
readFile(java.io.File file)
Read the content of the given file into a string, using UTF8 as default encoding
|
static java.lang.String |
readFile(java.io.File file,
java.lang.String encoding)
Read the content of the given file into a string.
|
static java.lang.String |
readFile(java.lang.String filename)
Read the content of the given file into a string.
|
static java.lang.String |
readReader(java.io.Reader reader)
Read the content of the given reader into a string.
|
static java.lang.String |
readResource(java.lang.String resource)
Read a resource from classpath using the context classloader, using UTF8 as default encoding
|
static java.lang.String |
readResource(java.lang.String resource,
java.lang.String encoding)
Read a resource from classpath using the context classloader
|
static java.lang.String |
readStream(java.io.InputStream stream)
Read the content of the given stream into a string.
|
static java.lang.String |
readStream(java.io.InputStream stream,
java.lang.String enconding)
Read the content of the given stream into a string.
|
public static java.lang.String readFile(java.lang.String filename)
throws java.io.IOException
filename - the name of the file to be readjava.io.IOException - if an error occurs during readreadFile(File)public static java.lang.String readFile(java.io.File file)
throws java.io.IOException
java.io.IOExceptionreadFile(File, String)public static java.lang.String readFile(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
file - the file to be readencoding - encoding to use, may be null in which case UTF-8 is used as defaultjava.io.IOException - if an error occurs during readpublic static java.lang.String readResource(java.lang.String resource)
throws java.io.IOException
java.io.IOExceptionreadResource(String, String)public static java.lang.String readResource(java.lang.String resource,
java.lang.String encoding)
throws java.io.IOException
resource - the resource name to read, must not be nullencoding - optional, may be null in which case UTF-8 is used as defaultjava.io.IOException - if the resource stream cannot be readpublic static java.lang.String readStream(java.io.InputStream stream)
throws java.io.IOException
stream - the contents to readjava.io.IOException - if the resource stream cannot be readreadStream(InputStream, String)public static java.lang.String readStream(java.io.InputStream stream,
java.lang.String enconding)
throws java.io.IOException
stream - the contents to readenconding - encoding to use, , may be null in which case UTF-8 is used as defaultjava.io.IOException - if the resource stream cannot be readpublic static java.lang.String readReader(java.io.Reader reader)
throws java.io.IOException
reader - the contents to readjava.io.IOException - if the resource stream cannot be read