public class TextFileReader extends Object
Constructor | Description |
---|---|
TextFileReader() |
Modifier and Type | Method | Description |
---|---|---|
String |
readText(File file) |
Read whole text from file line by line
|
String |
readText(File file,
String charset) |
Read whole text from file char by char
|
String |
readText(InputStream is,
String charset) |
Read whole text from file char by char
|
List<String> |
readTextAsList(File file) |
Read whole text as list from file line by line
|
List<String> |
readTextAsList(File file,
String charset) |
Read whole text as list from file line by line
|
List<String> |
readTextAsList(InputStream is,
String charset) |
Read whole text as list from inputStream line by line
|
List<String> |
readTextAsListFromResource(Class<?> clazz,
String fileName,
String charset,
String newLine) |
Read whole text from resource directory as List
|
List<String> |
readTextAsListWithRange(File file,
int beginLineNum,
int endLineNum) |
Read text as list from file line by line with range
|
List<String> |
readTextAsListWithRange(File file,
String charset,
int beginLineNum,
int endLineNum) |
Read text as list from file line by line with range
|
List<String> |
readTextAsListWithRange(InputStream is,
String charset,
int beginLineNum,
int endLineNum) |
Read text as list from inputStream line by line with range
|
String |
readTextCharByChar(File file) |
Read whole text char by char
|
String |
readTextCharByChar(File file,
String charset) |
Read whole text from file char by char
|
String |
readTextCharByChar(InputStream is,
String charset) |
Read whole text from input stream char by char
|
String |
readTextFromResource(Class<?> clazz,
String fileName,
String charset) |
Read whole text from resource directory
|
public String readTextCharByChar(File file) throws IOException
file
- IOException
public String readTextCharByChar(File file, String charset) throws IOException
file
- charset
- specify character set like 'UTF-8'IOException
public String readTextCharByChar(InputStream is, String charset) throws IOException
is
- charset
- specify character set like 'UTF-8'IOException
public String readText(File file) throws IOException
file
- IOException
public String readText(File file, String charset) throws IOException
file
- charset
- specify character set like 'UTF-8'IOException
public String readText(InputStream is, String charset) throws IOException
is
- charset
- IOException
public String readTextFromResource(Class<?> clazz, String fileName, String charset) throws IOException
clazz
- fileName
- charset
- IOException
-
Example
tr.readTextFromResource(this.getClass(),"res.properties","UTF-8");
public List<String> readTextAsListFromResource(Class<?> clazz, String fileName, String charset, String newLine) throws IOException
clazz
- fileName
- charset
- IOException
public List<String> readTextAsList(File file) throws IOException
file
- IOException
public List<String> readTextAsListWithRange(File file, int beginLineNum, int endLineNum) throws IOException
file
- beginLineNum
- line number starts with 0endLineNum
- IOException
public List<String> readTextAsList(File file, String charset) throws IOException
file
- charset
- specify character set like 'UTF-8'IOException
public List<String> readTextAsListWithRange(File file, String charset, int beginLineNum, int endLineNum) throws IOException
file
- charset
- specify character set like 'UTF-8'beginLineNum
- line number starts with 0endLineNum
- IOException
public List<String> readTextAsList(InputStream is, String charset) throws IOException
is
- charset
- IOException
public List<String> readTextAsListWithRange(InputStream is, String charset, int beginLineNum, int endLineNum) throws IOException
is
- charset
- beginLineNum
- line number starts with 0endLineNum
- IOException
Copyright © 2019. All rights reserved.