Android Utililty Methods Text File Read

List of utility methods to do Text File Read

Description

The list of methods to do Text File Read are organized into topic(s).

Method

ListfileToListByLine(String fileName)
file To List By Line
List<String> lineList = new LinkedList<String>();
String line = "";
BufferedReader in = null;
try {
    in = new BufferedReader(new FileReader(fileName));
    while ((line = in.readLine()) != null) {
        lineList.add(line);
} catch (Exception e) {
    throw e;
} finally {
    if (null != in) {
        in.close();
return lineList;
booleanfileToSet(final String dirname, final String filename, final Set set)
file To Set
return fileToSet(dirname, filename, set, logger);
StringgetFileContent(File file)
get File Content
Writer swriter = null;
Reader reader = null;
try {
    reader = new FileReader(file);
    swriter = new StringWriter();
    int len = 0;
    char[] buffer = new char[1024];
    while ((len = reader.read(buffer)) > 0) {
...
StringgetFileContent(File file, String charSet)
get File Content
ByteArrayOutputStream swriter = null;
OutputStream temp = null;
InputStream reader = null;
try {
    reader = new FileInputStream(file);
    swriter = new ByteArrayOutputStream();
    temp = new BufferedOutputStream(swriter);
    int len = 0;
...
StringgetFileResourceText(String path)
Gets the text from the URL resource.
BufferedReader fileReader = null;
StringBuilder stringBuilder = new StringBuilder();
try {
    fileReader = new BufferedReader(new FileReader(path));
    String line = null;
    while ((line = fileReader.readLine()) != null) {
        stringBuilder.append(line);
        stringBuilder.append(NEW_LINE);
...
Stringread(File file)
read
return read(file, false);
Listread(File file)
read
if (file != null) {
    try {
        return readFree(file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
return null;
Stringread(File file, boolean raw)
read
FileInputStream fis = new FileInputStream(file);
byte[] bytes = new byte[fis.available()];
fis.read(bytes);
fis.close();
String s = new String(bytes, StringPool.UTF8);
if (raw) {
    return s;
} else {
...
StringBufferread(String file)
read
BufferedReader in = null;
StringBuffer sb = new StringBuffer();
String s = null;
StringBuffer stringbuffer;
try {
    in = new BufferedReader(new FileReader(file));
    while ((s = in.readLine()) != null)
        sb.append(s).append('\n');
...
Stringread(String fileName)
read
return read(new File(fileName));