Here you can find the source of FiletoByteArray(File file)
Parameter | Description |
---|---|
file | File to Read |
public final static byte[] FiletoByteArray(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; public class Main { /**/*from www . j ava 2s .c om*/ * File to ByteArray * @param file File to Read * @return File's Buffer * @author Blue Electric */ public final static byte[] FiletoByteArray(File file) { try { FileInputStream fis = new FileInputStream(file); byte[] result = new byte[fis.available()]; fis.read(result); fis.close(); return result; } catch (Exception e) { e.printStackTrace(); return null; } } }