Java BufferedReader Read readFile(final File file)

Here you can find the source of readFile(final File file)

Description

read File

License

Open Source License

Declaration

public static String[] readFile(final File file) throws IOException 

Method Source Code

//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()]);
    }
}

Related

  1. readFile(File inputFile)
  2. readFile(File location)
  3. readFile(File path)
  4. readFile(File testPage)
  5. readFile(final File argFile)
  6. readFile(final File file)
  7. readFile(final File file)
  8. readFile(final File file)
  9. readFile(final File file)