Java BufferedReader Read readFile(String filename)

Here you can find the source of readFile(String filename)

Description

read File

License

Mozilla Public License

Declaration

public static String readFile(String filename) throws IOException 

Method Source Code

//package com.java2s;
/***************************************************************************
 * Copyright (C) 2004, Patrick Charles and Jonas Lehmann                   *
 * Distributed under the Mozilla Public License                            *
 *   http://www.mozilla.org/NPL/MPL-1.1.txt                                *
 ***************************************************************************/

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

import java.io.BufferedReader;

public class Main {
    public static String readFile(String filename) throws IOException {
        String readString = "";
        String tmp;//from  www.j  av  a2 s .com

        File f = new File(filename);
        char[] readIn = new char[(new Long(f.length())).intValue()];

        BufferedReader in = new BufferedReader(new FileReader(f));

        in.read(readIn);
        readString = new String(readIn);

        in.close();

        return readString;
    }
}

Related

  1. readFile(String fileName)
  2. readfile(String filename)
  3. readFile(String filename)
  4. readFile(String fileName)
  5. readFile(String fileName)
  6. readFile(String filename)
  7. readFile(String fileName)
  8. readFile(String fileName)
  9. readFile(String fileName)