Java BufferedReader Read readFile(File inputFile)

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

Description

read File

License

Mozilla Public License

Declaration

public static String readFile(File inputFile) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Mozilla Public License 

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

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

public class Main {
    private static final String NEW_LINE = System.getProperty("line.separator");

    private static String readFile(BufferedReader input) throws IOException {
        StringBuilder data = new StringBuilder();
        String line = null;// w ww .j a  va 2  s.  c o m
        while ((line = input.readLine()) != null) {
            data.append(line + NEW_LINE);
        }

        return data.toString();
    }

    public static String readFile(File inputFile) throws IOException {
        BufferedReader input = new BufferedReader(new FileReader(inputFile));
        return readFile(input);
    }

    public static String readFile(String inputFile) throws IOException {
        BufferedReader input = new BufferedReader(new FileReader(inputFile));
        return readFile(input);
    }
}

Related

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