read File using RandomAccessFile to byte array - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

read File using RandomAccessFile to byte array

Demo Code


//package com.java2s;

import java.io.File;

import java.io.IOException;
import java.io.RandomAccessFile;

public class Main {
    private static String readInstallationFile(File installation)
            throws IOException {
        RandomAccessFile f = new RandomAccessFile(installation, "r");
        byte[] bytes = new byte[(int) f.length()];
        f.readFully(bytes);//ww w  .  j a va  2s  . c  o m
        f.close();
        return new String(bytes);
    }
}

Related Tutorials