Java BufferedReader Read readFile(String fileName)

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

Description

read File

License

Apache License

Declaration

public static String readFile(String fileName) throws IOException 

Method Source Code


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

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

public class Main {
    public static String readFile(String fileName) throws IOException {
        StringBuilder sb = new StringBuilder();

        final BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
        String line = bufferedReader.readLine();
        while (line != null) {
            sb.append(line).append("\n");
            line = bufferedReader.readLine();
        }/*from   w  w  w  . j  a v a 2s .co  m*/

        return sb.toString();
    }
}

Related

  1. readFile(String file, Boolean deleteOnExit)
  2. readFile(String fileDir)
  3. readFile(String filename)
  4. readFile(String filename)
  5. readfile(String filename)
  6. readFile(String filename)
  7. readFile(String filename)
  8. readFile(String filename)
  9. readFile(String fileName)