Here you can find the source of readFile(String fileName)
public static byte[] readFile(String fileName)
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.FileInputStream; public class Main { public static byte[] readFile(String fileName) { try {//ww w. ja va2 s. c o m DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(fileName))); int n = in.available(); byte[] t = new byte[n]; int i = 0; while (in.available() != 0) { t[i] = in.readByte(); i++; } in.close(); return t; } catch (Exception e) { e.printStackTrace(); } return null; } }