Java BufferedReader Read readFileAsText(String path)

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

Description

read File As Text

License

Open Source License

Declaration

public static final String readFileAsText(String path) throws Exception 

Method Source Code

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

import java.io.*;

public class Main {

    public static final String readFileAsText(String path) throws Exception {
        FileReader reader = new FileReader(path);
        BufferedReader br = new BufferedReader(reader);

        try {//  w ww  .j  a va  2s.co  m
            String text = "";
            String line = null;

            while ((line = br.readLine()) != null) {
                text = text + line + "\n";
            }

            return text;
        } finally {
            br.close();
            reader.close();
        }
    }
}

Related

  1. readFileAsList(final String filename)
  2. readFileAsList(String filename, String splitter)
  3. readFileAsListOfString(String fileName, String splitBy)
  4. readFileAsListOfStrings(String filename)
  5. readFileAsListOfStrings(String filename)
  6. readFileByChar(String path)
  7. readFileContext(File fileToRead)
  8. readFileEncoding(String file)
  9. readFileGdeHash(File gdeFile, ArrayList name, ArrayList seq)