Here you can find the source of readFile(File file)
Parameter | Description |
---|---|
file | - The file to read. |
public static byte[] readFile(File file)
//package com.java2s; //License from project: Apache License import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; public class Main { /**/*from w w w . ja va 2 s . com*/ * Reads a file, and returns all bytes from that file. * @param file - The file to read. * @return A byte array containing every byte from the file. */ public static byte[] readFile(File file) { BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); byte[] d = new byte[in.available()]; in.read(d); return d; } catch (Exception exception) { exception.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (Exception exception) { exception.printStackTrace(); } } } return null; } }