Android File to Byte Array Read getByteFromFile(String fileName)

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

Description

get Byte From File

Declaration

public static byte[] getByteFromFile(String fileName) throws Exception 

Method Source Code

//package com.java2s;

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

public class Main {
    public static byte[] getByteFromFile(String fileName) throws Exception {
        File file = new File(fileName);
        FileInputStream fis = new FileInputStream(file);
        int length = fis.available();
        byte[] buffer = new byte[length];
        fis.read(buffer);//from   w w w  .ja  va2  s.  co m
        fis.close();
        return buffer;
    }
}

Related

  1. buildDataFromFile(File file)
  2. buildDataFromFile(String path)
  3. buildDataFromFile(String path, int bufferSize)
  4. file2byte(File file)
  5. file2byte(String path)
  6. getAvailableBytes(File root)
  7. getAvailableBytes(File root)
  8. getByteArrayFromSD(String path)