Here you can find the source of readFile(final File file)
public static String[] readFile(final File file) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2010, 2013 TH4 SYSTEMS GmbH and others. * 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:/* www. j a va 2 s . c o m*/ * TH4 SYSTEMS GmbH - initial API and implementation *******************************************************************************/ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Main { public static String[] readFile(final File file) throws IOException { final BufferedReader reader = new BufferedReader(new FileReader(file)); final List<String> content = new ArrayList<String>(); try { String line = null; while ((line = reader.readLine()) != null) { content.add(line); } } finally { reader.close(); } return content.toArray(new String[content.size()]); } }