Here you can find the source of readFile(File file)
Parameter | Description |
---|---|
file | a parameter |
public static byte[] readFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { /**/*w w w. j a v a2 s.co m*/ * Reads a file in binary format * * @param file * @return */ public static byte[] readFile(File file) { byte[] b = new byte[(int) file.length()]; try { FileInputStream fs = new FileInputStream(file); fs.read(b); // for (int i = 0; i < b.length; i++) { // System.out.print((char) b[i]); // } fs.close(); } catch (FileNotFoundException e) { System.out.println("File Not Found."); e.printStackTrace(); } catch (IOException e1) { System.out.println("Error Reading The File."); e1.printStackTrace(); } return b; } }