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

Listread(String pathName)
read
if (pathName != null) {
    try {
        return readFree(new File(pathName));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
return null;
String[]readCipherSuites(String file)
Read SSL/TLS cipher suites from a file.
try {
    return readLines(file);
} catch (IOException ioe) {
    System.err.println("Error reading cipher suits from: " + file);
    System.err.println(ioe.getMessage());
    return null;
String[]readClasspathTextFile(String filename)
read Classpath Text File
String filenameCp = findClasspathFile(filename);
if (filenameCp == null) {
    throw new RuntimeException("Failed to find file '" + filename
            + "' in classpath");
List<String> lines = new ArrayList<String>();
try {
    FileInputStream fis = new FileInputStream(filenameCp);
...
StringreadFile(File file)
read File
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
StringBuffer pageBuffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
    pageBuffer.append(line);
return pageBuffer.toString();
StringreadFile(File file)
Reads file and returns contents as string
String filePath = file.getAbsolutePath();
FileInputStream fstream = new FileInputStream(filePath);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
String forReturn = "";
try {
    while ((strLine = br.readLine()) != null) {
...
StringreadFile(File file)
Reads the specified file and returns the content as a String.
StringBuffer stringBuffer = new StringBuffer();
BufferedReader reader = Files.newBufferedReader(file.toPath(),
        CHARSET);
String line = null;
while ((line = reader.readLine()) != null) {
    stringBuffer.append(line);
reader.close();
...
StringreadFile(File file, String encoding)
read File
return readFile(new FileInputStream(file), encoding);
StringreadFile(File in)
read File
try {
    return readFile(new FileInputStream(in));
} catch (Exception e) {
    e.printStackTrace();
    return null;
StringreadFile(String fileName)
read File
try {
    File adfile = new File(fileName);
    StringBuffer content = new StringBuffer();
    if (adfile.isFile() && adfile.exists()) {
        InputStreamReader read = new InputStreamReader(
                new FileInputStream(adfile),
                Charset.defaultCharset());
        BufferedReader in = new BufferedReader(read);
...
StringreadFile(String fileName)
read File
File file = new File(fileName);
StringBuffer contents = new StringBuffer();
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(file));
    String text = null;
    while ((text = reader.readLine()) != null) {
        contents.append(text).append(
...