Java FileInputStream Read readFile(String file)

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

Description

Read File and return byte[]

License

Open Source License

Parameter

Parameter Description
file a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static byte[] readFile(String file) throws Exception 

Method Source Code

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

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

public class Main {
    /**//from  w ww .j a  v a 2 s . c o m
     * Read File and return byte[]
     * @param file
     * @return
     * @throws Exception
     */
    public static byte[] readFile(String file) throws Exception {

        FileInputStream fis = new FileInputStream(new File(file));
        byte[] data = new byte[fis.available()];
        fis.read(data);
        fis.close();

        return data;
    }
}

Related

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