Example usage for java.io RandomAccessFile readFully

List of usage examples for java.io RandomAccessFile readFully

Introduction

In this page you can find the example usage for java.io RandomAccessFile readFully.

Prototype

public final void readFully(byte b[]) throws IOException 

Source Link

Document

Reads b.length bytes from this file into the byte array, starting at the current file pointer.

Usage

From source file:org.telegram.ui.PassportActivity.java

private EncryptionResult createSecureDocument(String path) {
    File file = new File(path);
    int length = (int) file.length();
    byte[] b = new byte[length];
    RandomAccessFile f = null;
    try {/*ww w  .  j  av a  2  s  .c o  m*/
        f = new RandomAccessFile(path, "rws");
        f.readFully(b);
    } catch (Exception ignore) {

    }
    EncryptionResult result = encryptData(b);
    try {
        f.seek(0);
        f.write(result.encryptedData);
        f.close();
    } catch (Exception ignore) {

    }
    return result;
}