Java Text File Read getFileContents(String path)

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

Description

get File Contents

License

Open Source License

Declaration

static Vector<String> getFileContents(String path) 

Method Source Code


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

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Vector;

public class Main {
    static Vector<String> getFileContents(String path) {

        Vector<String> words = new Vector<String>();

        try {//from w  w  w . j av  a2 s. c om
            FileInputStream fstream = new FileInputStream(path);

            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;

            while ((strLine = br.readLine()) != null) {
                words.add(strLine);
            }

            in.close();

        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());

            return new Vector<String>();
        }

        return (words);
    }
}

Related

  1. getFileContents(Reader reader)
  2. getFileContents(String filePath)
  3. getFileContents(String filePath)
  4. getFileContents(String filePath)
  5. getFileContents(String filePath)
  6. getFileContents(String pathToFile)
  7. getFileContents(String pFileName)
  8. loadAsString(String location)
  9. readFile(String filePath)