Android BufferedReader Read getFileContent(File f)

Here you can find the source of getFileContent(File f)

Description

get File Content

Declaration

public static StringBuilder getFileContent(File f) 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class Main {
    public static StringBuilder getFileContent(File f) {
        StringBuilder tmp = new StringBuilder();

        try {//from  ww  w  . j  a  v  a2 s .  c  om
            @SuppressWarnings("resource")
            BufferedReader br = new BufferedReader(new FileReader(f));

            String line;
            while ((line = br.readLine()) != null) {
                tmp.append(line);
                tmp.append("\n");
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return tmp;
    }
}

Related

  1. readFileAsString(File file)
  2. readFileFolder(String filePath)
  3. readStream(Reader r)
  4. readStringFromBufferedReader(BufferedReader br)