Java FileInputStream Read readFileBinary(String filename)

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

Description

read File Binary

License

Open Source License

Declaration

public static byte[] readFileBinary(String filename) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {
    public static byte[] readFileBinary(String filename) throws IOException {

        File file = new File(filename);
        byte[] data = new byte[(int) file.length()];
        DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
        dis.readFully(data);//from w  ww.  ja v a  2s . c  om
        dis.close();

        return data;
    }
}

Related

  1. readFileAsProperties(File file)
  2. readFileAsResource(String fileName)
  3. ReadFileAsUtf8String(String filePath)
  4. readFileAtOnce(final File file)
  5. readFileBinaries(File file)
  6. readFileBytes(File file)
  7. readFileBytes(File file)
  8. readFileBytes(String file)
  9. readFileBytes(String filename)