Android Utililty Methods File to Byte Array Read

List of utility methods to do File to Byte Array Read

Description

The list of methods to do File to Byte Array Read are organized into topic(s).

Method

byte[]buildDataFromFile(String path, int bufferSize)
build Data From File
InputStream is = null;
File file = new File(path);
if (!file.exists()) {
    return null;
try {
    is = new FileInputStream(file);
} catch (Exception e1) {
...
byte[]file2byte(File file)
filebyte
byte[] data = null;
FileInputStream input = null;
try {
    input = new FileInputStream(file);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    byte[] buf = new byte[1024];
    int numBytesRead = 0;
    while ((numBytesRead = input.read(buf)) != -1) {
...
byte[]file2byte(String path)
filebyte
byte[] data = null;
data = file2byte(new File(path));
return data;
byte[]getByteFromFile(String fileName)
get Byte From File
File file = new File(fileName);
FileInputStream fis = new FileInputStream(file);
int length = fis.available();
byte[] buffer = new byte[length];
fis.read(buffer);
fis.close();
return buffer;
longgetAvailableBytes(File root)
get Available Bytes
StatFs stat = new StatFs(root.getPath());
long availableBlocks = (long) stat.getAvailableBlocks() - 4;
return stat.getBlockSize() * availableBlocks;
longgetAvailableBytes(File root)
get Available Bytes
StatFs stat = new StatFs(root.getPath());
long availableBlocks = (long) stat.getAvailableBlocks() - 4;
return stat.getBlockSize() * availableBlocks;
byte[]getByteArrayFromSD(String path)
get Byte Array From SD
byte[] bytes = null;
ByteArrayOutputStream out = null;
try {
    File file = new File(path);
    if (!isCanUseSD()) {
        return null;
    if (!file.exists()) {
...