Here you can find the source of readFile(File src)
public static byte[] readFile(File src) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2009 Oracle. 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. * /*from w ww . j a v a2 s .co m*/ * Contributors: * Oracle - initial API and implementation ******************************************************************************/ import java.io.File; import java.io.IOException; public class Main { public static byte[] readFile(File src) throws IOException { java.io.FileInputStream fin = new java.io.FileInputStream(src); try { long fileLen = src.length(); if (fileLen > Integer.MAX_VALUE) throw new IOException("file length too big to be read by FileUtil.readFile: " + fileLen); byte[] bytes = new byte[(int) fileLen]; fin.read(bytes); return bytes; } finally { fin.close(); } } }