Java FileReader Create readTextFile(String path)

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

Description

read Text File

License

BSD License

Declaration

static public String readTextFile(String path) throws IOException 

Method Source Code

//package com.java2s;
// LICENSE:      This file is distributed under the BSD license.

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

public class Main {
    static public String readTextFile(String path) throws IOException {
        String newLine = System.getProperty("line.separator");
        StringBuffer sb = new StringBuffer();
        BufferedReader input = new BufferedReader(new FileReader(path));
        String line;/*from  w  w  w  . j  av a  2  s.  c  o  m*/
        while (null != (line = input.readLine())) {
            if (sb.length() > 0)
                sb.append(newLine);
            sb.append(line);
        }

        return sb.toString();
    }
}

Related

  1. readTextFile(String filePath)
  2. readTextFile(String filePath)
  3. readTextFile(String filePath)
  4. readTextFile(String fullPathFilename)
  5. readTextFile(String path)
  6. readTextFile(String text_file_name)
  7. readTextFile(String text_file_name)
  8. readTextFileAsList(File file)
  9. readTextFileContents(File fFile)