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) throws java.io.IOException 

Method Source Code


//package com.java2s;
import java.io.BufferedReader;

import java.io.File;
import java.io.FileReader;

public class Main {
    public static String readFile(File f) throws java.io.IOException {
        StringBuffer fileData = new StringBuffer(1000);
        BufferedReader reader = new BufferedReader(new FileReader(f));
        char[] buf = new char[1024];
        int numRead = 0;
        while ((numRead = reader.read(buf)) != -1) {
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);// w w  w . j a  v  a2  s  .  co m
            buf = new char[1024];
        }
        reader.close();

        return fileData.toString();
    }
}

Related

  1. readFile(File f)
  2. readFile(File f)
  3. readFile(File f)
  4. readFile(File f)
  5. readFile(File f)
  6. readFile(File f)
  7. ReadFile(File f, boolean keep_newline)
  8. readFile(File f, boolean preserveLineBreaks)
  9. readFile(File f, String newLineChar)