Android Text File Read readFile(String filePath)

Here you can find the source of readFile(String filePath)

Description

read File

Declaration

public static String readFile(String filePath) throws IOException 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;

import java.io.DataInputStream;

import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static String readFile(String filePath) throws IOException {
        String result = new String();

        FileInputStream fstream = new FileInputStream(filePath);
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine;//from w w w.  j av a 2s .  c  o m
        while ((strLine = br.readLine()) != null) {
            result += strLine + "\n";
        }
        in.close();
        return result;
    }
}

Related

  1. readFile(File file)
  2. readFile(File file, String encoding)
  3. readFile(File in)
  4. readFile(String fileName)
  5. readFile(String fileName)
  6. readFile(String filename)
  7. readFile(String path)
  8. readFileAsString(File file)
  9. readFileAsString(File file, String charset)