Java BufferedReader Read readFile(String path)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String path) throws Exception 

Method Source Code


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

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

import java.io.FileReader;

public class Main {

    public static String readFile(String path) throws Exception {
        File file = new File(path);
        FileReader fileReader = new FileReader(file);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        StringBuffer stringBuffer = new StringBuffer();
        String str;/*from  ww  w.j a va2s .com*/
        str = bufferedReader.readLine();
        while (str != null) {
            stringBuffer.append(str);
            stringBuffer.append("\r\n");
            str = bufferedReader.readLine();
        }
        bufferedReader.close();
        fileReader.close();
        return stringBuffer.toString();
    }
}

Related

  1. readFile(String fullPath)
  2. readFile(String fullPath)
  3. readFile(String nameFile)
  4. readFile(String path)
  5. readFile(String path)
  6. readFile(String path)
  7. readFile(String path)
  8. readFile(String path)
  9. readFile(String path)