Here you can find the source of getBytes(File file)
public static byte[] getBytes(File file) throws IOException
//package com.java2s; import java.io.*; public class Main { public static byte[] getBytes(File file) throws IOException { FileInputStream fileInputStream = new FileInputStream(file); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bytes = new byte[1024]; int n = 0; while ((n = fileInputStream.read(bytes)) != -1) { byteArrayOutputStream.write(bytes, 0, n); }/*from w ww.j av a2 s. c o m*/ byteArrayOutputStream.close(); fileInputStream.close(); return byteArrayOutputStream.toByteArray(); } }