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