Java BufferedReader Read readFile(final String pFile)

Here you can find the source of readFile(final String pFile)

Description

read File

License

Open Source License

Declaration

public static StringBuilder readFile(final String pFile) 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 StringBuilder readFile(final String pFile) throws Exception {
        File bsCWT = new File(pFile);
        @SuppressWarnings("resource")
        BufferedReader reader = new BufferedReader(new FileReader(bsCWT));
        StringBuilder content = new StringBuilder();
        String line;//from  w ww .j  a  v a2s.c  om
        while ((line = reader.readLine()) != null) {
            // add file line by line to StringBuiler
            content.append(line + "\n");
        }
        return content;
    }
}

Related

  1. readFile(final String filename)
  2. readFile(final String fileName)
  3. readFile(final String filePath)
  4. readFile(final String name)
  5. readFile(final String path)
  6. readFile(List fieldNames, String filename)
  7. readFile(Reader reader)
  8. readFile(String absoluteFilePath)
  9. readFile(String aFileName)