Java FileReader Read readFile(String fileName)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String fileName) throws IOException 

Method Source Code


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

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

public class Main {
    public static String readFile(String fileName) throws IOException {
        String content;//  w w w  . j  ava2 s.c o m
        File file = new File(fileName);

        FileReader reader = new FileReader(file);
        char[] chars = new char[(int) file.length()];
        reader.read(chars);
        content = new String(chars);
        reader.close();

        return content;
    }
}

Related

  1. readFile(String file)
  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)