Java BufferedReader Read Line readLineFile(File file)

Here you can find the source of readLineFile(File file)

Description

read Line File

License

Open Source License

Declaration

public static String[] readLineFile(File file) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.File;

import java.io.FileReader;

import java.io.IOException;

public class Main {
    public static String[] readLineFile(File file) throws IOException {
        BufferedReader a = null;/* ww w  . j ava  2s . c  o m*/
        String[] d = null;
        try {
            a = new BufferedReader(new FileReader(file));
            String b;
            int c = 0;
            String[] e = null;
            b = a.readLine();
            while (b != null) {
                e = new String[c + 1];
                if (d != null) {
                    System.arraycopy(d, 0, e, 0, d.length);
                } else {
                    d = new String[1];
                }
                e[c] = b;
                d = e.clone();
                c++;
                b = a.readLine();
            }
        } finally {
            if (a != null) {
                a.close();
            }
        }
        if (d != null) {
            return d.clone();
        } else {
            return null;
        }
    }
}

Related

  1. readLine(String prompt, boolean force)
  2. readLine(String s)
  3. readLine(String s)
  4. readLine(String value, BufferedReader procout)
  5. readLineByLine(File file, char[][] terminators, boolean keepTerminators, Consumer readLineListener)
  6. readLineFile(String filePath)
  7. readLineFromCommand(String command[])
  8. readLineFromConsole()
  9. readLineHard(BufferedReader in)