Java FileInputStream Read readFileToBytes(File f)

Here you can find the source of readFileToBytes(File f)

Description

read File To Bytes

License

Apache License

Declaration

public static byte[] readFileToBytes(File f) throws IOException 

Method Source Code

//package com.java2s;
/**//from   w w w.  j  av a2 s.c om
 * SlingBeans - NetBeans Sling plugin https://github.com/jkan997/SlingBeans Licensed under Apache 2.0 license http://www.apache.org/licenses/LICENSE-2.0
 */

import java.io.*;

public class Main {
    public static byte[] readFileToBytes(File f) throws IOException {
        int fLen = (int) f.length();
        byte[] res = new byte[fLen];
        FileInputStream fis = new FileInputStream(f);
        fis.read(res);
        fis.close();
        return res;
    }
}

Related

  1. readFileToByteArray(File file)
  2. readFileToByteArray(File file)
  3. readFileToByteArray(File file)
  4. readFileToByteArray(String file)
  5. readFileToByteArray(String filename)
  6. readFileToBytes(File f, int max)
  7. readFileToBytes(String path)
  8. readFileToStr(String fn, String charset)
  9. readFileUTF8(String file)