Java BufferedReader Read readFile(String filePath)

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

Description

read File

License

Apache License

Declaration

public static String readFile(String filePath) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.File;

import java.io.FileReader;

import java.io.IOException;

public class Main {
    public static String readFile(String filePath) {
        try {/*from w  w w.  j  av  a2 s.c o m*/
            BufferedReader br = new BufferedReader(new FileReader(new File(filePath)));
            StringBuffer sb = new StringBuffer();
            String line = null;
            while ((line = br.readLine()) != null) {
                sb.append(line + "\n");
            }
            return sb.toString();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. readFile(String filePath)
  2. readFile(String filePath)
  3. readFile(String filePath)
  4. readFile(String filePath)
  5. readFile(String filePath)
  6. readFile(String filePath, Boolean replaceNewLineWithBr)
  7. readFile(String fullPath)
  8. readFile(String fullPath)
  9. readFile(String nameFile)