Java BufferedReader Read readFile(File f)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(File f) 

Method Source Code


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

import java.io.BufferedReader;
import java.io.File;

import java.io.FileNotFoundException;

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

public class Main {
    public static String readFile(File f) {
        try (BufferedReader br = new BufferedReader(new FileReader(f))) {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);/*from ww  w  . j a va 2s. c  om*/
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            return sb.toString();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. loadWaypoints(File inFile)
  2. loadXML(String fileName)
  3. loadXMLDocumentFromClasspath(String resourcePath)
  4. loadY(InputStream filePath)
  5. readFile(File f)
  6. readFile(File f)
  7. readFile(File f)
  8. readFile(File f)
  9. readFile(File f)