Java Text File Read All readAllFile(String fileName)

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

Description

read All File

License

LGPL

Declaration

public static byte[] readAllFile(String fileName) throws IOException 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStream;

public class Main {

    public static byte[] readAllFile(String fileName) throws IOException {
        InputStream is = new FileInputStream(fileName);
        try {//from ww w.j  a v  a 2 s. com
            int n = is.available();
            byte[] data = new byte[n];
            is.read(data);
            return data;
        } finally {
            is.close();
        }
    }
}

Related

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