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;
/*/*www. j av  a 2 s  . co  m*/
 * This file is part of the OpenSCADA project
 * Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
 *
 * OpenSCADA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenSCADA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenSCADA. If not, see
 * <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
 */

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>();

        String line = null;
        while ((line = reader.readLine()) != null) {
            content.add(line);
        }

        return content.toArray(new String[content.size()]);
    }
}

Related

  1. readFile(File path)
  2. readFile(File testPage)
  3. readFile(final File argFile)
  4. readFile(final File file)
  5. readFile(final File file)
  6. readFile(final File file)
  7. readFile(final File file)
  8. readFile(final File paramFile, final boolean paramWhitespaces)
  9. readFile(final String file)