Here you can find the source of getBytes(File file)
public static byte[] getBytes(File file)
//package com.java2s; import java.io.File; import java.io.FileInputStream; public class Main { public static byte[] getBytes(File file) { FileInputStream inputStream = null; byte[] fileContent = null; try {/*from ww w . j ava2 s. com*/ inputStream = new FileInputStream(file); fileContent = new byte[(int) file.length()]; inputStream.read(fileContent); } catch (Exception e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (Exception ex) { ex.printStackTrace(); } } return fileContent; } }