Java FileReader Create readTextFile(File file)

Here you can find the source of readTextFile(File file)

Description

read Text File

License

Apache License

Parameter

Parameter Description
file a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static String readTextFile(File file) throws IOException 

Method Source Code

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

import java.io.*;

public class Main {
    /**/*  w  w  w.  jav a 2  s  .  c om*/
     * @param file
     * @return
     * @throws IOException
     */
    public static String readTextFile(File file) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(file));
        String line;
        String fileContent = "";
        while ((line = reader.readLine()) != null) {
            fileContent += line.trim();
        }
        reader.close();
        return fileContent;
    }
}

Related

  1. readTextFile(File aFile)
  2. readTextFile(File f)
  3. readTextFile(File f)
  4. readTextFile(File file)
  5. readTextFile(File file)
  6. readTextFile(File file)
  7. readTextFile(File file)
  8. readTextFile(File file)
  9. readTextFile(File file)