public final class ReadFileExtensions
extends java.lang.Object
ReadFileExtensions helps you reading files.| Modifier and Type | Method and Description |
|---|---|
static java.lang.Byte[] |
getFilecontentAsByteObjectArray(java.io.File tmpFile)
Get a Byte array from the given file.
|
static java.lang.String |
inputStream2String(java.io.InputStream inputStream)
The Method inputStream2String() reads the data from the InputStream into a String.
|
static java.lang.String |
inputStream2String(java.io.InputStream inputStream,
java.nio.charset.Charset encoding)
The Method inputStream2String() reads the data from the InputStream into a String.
|
static java.io.Reader |
openFileReader(java.lang.String fileName)
The Method openFileReader() opens a BufferedReader from the given file.
|
static java.lang.String |
reader2String(java.io.Reader reader)
The Method reader2String() reads the data from the Reader into a String.
|
static byte[] |
readFileToBytearray(java.io.File file)
Get a byte array from the given file.
|
static java.lang.String |
readFromFile(java.io.File file)
The Method readFromFile() reads the filecontent to a String.
|
static java.lang.String |
readFromFile(java.io.File file,
java.nio.charset.Charset encoding)
Read from file.
|
static java.lang.String |
readHeadLine(java.lang.String inputFile)
The Method readHeadLine() opens the File and reads the first line from the file.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.File input)
Reads every line from the File and puts them to the List.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.File input,
boolean trim)
Reads every line from the File and puts them to the List.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.File input,
java.nio.charset.Charset encoding)
Reads every line from the File and puts them to the List.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.File input,
java.nio.charset.Charset encoding,
boolean trim)
Reads every line from the File and puts them to the List.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.InputStream input)
Reads every line from the given InputStream and puts them to the List.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.InputStream input,
boolean trim)
Reads every line from the given InputStream and puts them to the List.
|
static java.util.List<java.lang.String> |
readLinesInList(java.io.InputStream input,
java.nio.charset.Charset encoding,
boolean trim)
Reads every line from the given InputStream and puts them to the List.
|
static java.util.Properties |
readPropertiesFromFile(java.lang.String filename)
The Method readFromFile(String) reads from the properties-file all Properties and saves them
into a Properties-Object.
|
static byte[] |
toByteArray(java.io.File tmpFile)
Get a byte array from the given file.
|
static byte[] |
toByteArray(java.io.InputStream input)
Get a byte array from the given
InputStream. |
public static java.lang.Byte[] getFilecontentAsByteObjectArray(java.io.File tmpFile)
throws java.io.IOException
tmpFile - the tmp filejava.io.IOException - Signals that an I/O exception has occurred.public static java.lang.String inputStream2String(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - The InputStream from where we read.java.io.IOException - Signals that an I/O exception has occurred.public static java.lang.String inputStream2String(java.io.InputStream inputStream,
java.nio.charset.Charset encoding)
throws java.io.IOException
inputStream - The InputStream from where we read.encoding - the encodingjava.io.IOException - Signals that an I/O exception has occurred.public static java.io.Reader openFileReader(java.lang.String fileName)
throws java.io.IOException
fileName - The file from where to read.java.io.IOException - Signals that an I/O exception has occurred.public static java.lang.String reader2String(java.io.Reader reader)
throws java.io.IOException
reader - The Reader from where we read.java.io.IOException - Signals that an I/O exception has occurred.public static byte[] readFileToBytearray(java.io.File file)
throws java.io.IOException
file - The file.java.io.IOException - Signals that an I/O exception has occurred.public static java.lang.String readFromFile(java.io.File file)
throws java.io.IOException
file - The File to read to a String.java.io.IOException - Signals that an I/O exception has occurred.public static java.lang.String readFromFile(java.io.File file,
java.nio.charset.Charset encoding)
throws java.io.IOException
file - the fileencoding - the encodingjava.io.IOException - Signals that an I/O exception has occurred.public static java.lang.String readHeadLine(java.lang.String inputFile)
throws java.io.FileNotFoundException,
java.io.IOException
inputFile - The Path to the File and name from the file from where we read.java.io.FileNotFoundException - the file not found exceptionjava.io.IOException - Signals that an I/O exception has occurred.public static java.util.List<java.lang.String> readLinesInList(java.io.File input)
throws java.io.FileNotFoundException,
java.io.IOException
input - The File from where the input comes.java.io.FileNotFoundException - is thrown if the given file is not found.java.io.IOException - Signals that an I/O exception has occurred.public static java.util.List<java.lang.String> readLinesInList(java.io.File input,
boolean trim)
throws java.io.FileNotFoundException,
java.io.IOException
input - The File from where the input comes.trim - the flag trim if the lines shell be trimed.java.io.FileNotFoundException - is thrown if the given file is not found.java.io.IOException - Signals that an I/O exception has occurred.public static java.util.List<java.lang.String> readLinesInList(java.io.File input,
java.nio.charset.Charset encoding)
throws java.io.FileNotFoundException,
java.io.IOException
input - The File from where the input comes.encoding - the encodingjava.io.FileNotFoundException - is thrown if the given file is not found.java.io.IOException - When a io-problem occurs.public static java.util.List<java.lang.String> readLinesInList(java.io.File input,
java.nio.charset.Charset encoding,
boolean trim)
throws java.io.FileNotFoundException,
java.io.IOException
input - The File from where the input comes.encoding - the charset for readtrim - the flag trim if the lines shell be trimed.java.io.FileNotFoundException - is thrown if the given file is not found.java.io.IOException - When a io-problem occurs.public static java.util.List<java.lang.String> readLinesInList(java.io.InputStream input)
throws java.io.IOException
input - The InputStream from where the input comes.java.io.IOException - When a io-problem occurs.public static java.util.List<java.lang.String> readLinesInList(java.io.InputStream input,
boolean trim)
throws java.io.IOException
input - The InputStream from where the input comes.trim - the flag trim if the lines shell be trimed.java.io.IOException - When a io-problem occurs.public static java.util.List<java.lang.String> readLinesInList(java.io.InputStream input,
java.nio.charset.Charset encoding,
boolean trim)
throws java.io.IOException
input - The InputStream from where the input comes.encoding - the charset for readtrim - the flag trim if the lines shell be trimed.java.io.IOException - When a io-problem occurs.public static java.util.Properties readPropertiesFromFile(java.lang.String filename)
throws java.io.IOException
filename - The Filename from the Properties-file.java.io.IOException - Signals that an I/O exception has occurred.public static byte[] toByteArray(java.io.File tmpFile)
throws java.io.IOException
tmpFile - The file.java.io.IOException - Signals that an I/O exception has occurred.public static byte[] toByteArray(java.io.InputStream input)
throws java.io.IOException
InputStream.input - The InputStream.java.io.IOException - Signals that an I/O exception has occurred.java.lang.NullPointerException - if the input is null