Java BufferedReader Read readFile(String nameFile)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String nameFile) throws IOException 

Method Source Code


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

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Main {
    public static String readFile(String nameFile) throws IOException {
        StringBuilder sb = new StringBuilder("");
        BufferedReader br = null;
        try {/*from   w w  w . j  a  v a  2 s.  c o  m*/
            br = new BufferedReader(new FileReader(nameFile));
            String linea;
            while ((linea = br.readLine()) != null) {
                sb.append(linea);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            br.close();
        }
        return sb.toString();
    }
}

Related

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