Java BufferedReader Read readFile(File location)

Here you can find the source of readFile(File location)

Description

read File

License

Open Source License

Declaration

public static String readFile(File location) 

Method Source Code

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

import java.io.*;

public class Main {
    public static String readFile(File location) {
        if (!location.exists())
            return null;
        BufferedReader br = null;
        StringBuilder bldr = new StringBuilder();
        try {/*w  ww. ja va2 s .  c o m*/
            String sCurrentLine;
            br = new BufferedReader(new FileReader(location));
            while ((sCurrentLine = br.readLine()) != null) {
                bldr.append(sCurrentLine + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (br != null)
                    br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return bldr.toString();
    }
}

Related

  1. readFile(File file, int header)
  2. readFile(File filename)
  3. readFile(File from)
  4. readFile(File in)
  5. readFile(File inputFile)
  6. readFile(File path)
  7. readFile(File testPage)
  8. readFile(final File argFile)
  9. readFile(final File file)