Android Utililty Methods BufferedReader Read

List of utility methods to do BufferedReader Read

Description

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

Method

StringBuildergetFileContent(File f)
get File Content
StringBuilder tmp = new StringBuilder();
try {
    @SuppressWarnings("resource")
    BufferedReader br = new BufferedReader(new FileReader(f));
    String line;
    while ((line = br.readLine()) != null) {
        tmp.append(line);
        tmp.append("\n");
...
StringreadFileAsString(File file)
read File As String
StringBuilder sb = new StringBuilder(1000);
BufferedReader reader = new BufferedReader(new FileReader(file));
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
    sb.append(buf, 0, numRead);
reader.close();
...
voidreadFileFolder(String filePath)
read File Folder
File file = new File(filePath);
if (file.exists()) {
    if (file.isDirectory()) {
        System.out.println(file.getName());
        File[] files = file.listFiles();
        if (files != null && files.length > 0) {
            for (File f : files) {
                System.out.println(f.getName());
...
StringreadStream(Reader r)
Puts the whole stream into the string.
StringBuffer buffer = new StringBuffer();
BufferedReader br = new BufferedReader(r);
String line;
while ((line = br.readLine()) != null) {
    buffer.append(line);
return buffer.toString();
StringreadStringFromBufferedReader(BufferedReader br)
Reads all content from the given Reader and returns it as a single String
StringBuffer sbr = new StringBuffer();
for (String ln = br.readLine(); ln != null; ln = br.readLine())
    sbr.append(ln + "\n");
br.close();
return sbr.toString();
ListtoList(String fileName)
to List
try {
    return toList(new FileReader(fileName));
} catch (IOException ioe) {
    return new ArrayList();