Java Text File Read All readAllFile(File file)

Here you can find the source of readAllFile(File file)

Description

read All File

License

Open Source License

Declaration

public static String readAllFile(File file) 

Method Source Code

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

import java.io.File;
import java.io.FileInputStream;

public class Main {
    public static String readAllFile(File file) {
        try {/*  www.ja v  a2 s  .c o m*/
            FileInputStream i = new FileInputStream(file);
            byte[] r = new byte[(int) file.length()];
            i.read(r);
            return new String(r);
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. readAll(File file)
  2. readAll(File file)
  3. readAll(final String path)
  4. readAllFile(String fileName)
  5. readAllText(final String filename)