Java BufferedReader Read readFile(String path)

Here you can find the source of readFile(String path)

Description

Reads a file into a Vector of Strings

License

Open Source License

Declaration

public static Vector<String> readFile(String path) 

Method Source Code


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

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;
import java.util.Vector;

public class Main {
    /**//  w  w w .  j  av  a  2  s  .  c om
     * Reads a file into a Vector of Strings
     */
    public static Vector<String> readFile(String path) {
        BufferedReader reader = null;
        Vector<String> contents = new Vector<String>();
        try {
            reader = new BufferedReader(new FileReader(path));
            String line;
            while ((line = reader.readLine()) != null)
                contents.add(line);
        } catch (Exception ex) {
            System.err.println(ex);
        } finally {
            try {
                if (reader != null)
                    reader.close();
            } catch (IOException ex) {
            }
        }
        return contents;
    }
}

Related

  1. readFile(String path)
  2. readFile(String path)
  3. readFile(String path)
  4. readFile(String path)
  5. readFile(String path)
  6. readFile(String path)
  7. readFile(String path)
  8. readFile(String path)
  9. readFile(String path)