Here you can find the source of readFile(String fileName)
public static byte[] readFile(String fileName) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 Kaloyan Raev.//from w w w .j av a 2 s. c om * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Kaloyan Raev - initial API and implementation *******************************************************************************/ import java.io.FileInputStream; import java.io.IOException; public class Main { public static byte[] readFile(String fileName) throws IOException { FileInputStream in = new FileInputStream(fileName); byte[] bytes = new byte[in.available()]; in.read(bytes); in.close(); return bytes; } }