Java BufferedReader Read readFile(String filePath)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String filePath) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static String readFile(String filePath) throws IOException {
        BufferedReader reader = null;
        try {//from   ww w  . j  a va 2  s .  c  o  m
            reader = new BufferedReader(new FileReader(filePath));
            StringBuilder sb = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
                sb.append("\n");
            }
            return sb.toString();
        } finally {
            if (reader != null)
                reader.close();
        }
    }
}

Related

  1. readFile(String fileName, String commentFlag)
  2. readFile(String fileName, String commentFlag)
  3. readFile(String fileNm)
  4. readFile(String filePath)
  5. readFile(String filePath)
  6. readFile(String filePath)
  7. readFile(String filePath)
  8. readFile(String filePath)
  9. readFile(String filePath, Boolean replaceNewLineWithBr)