Java InputStreamReader Read readFileData(String directoryLocation, String fileName)

Here you can find the source of readFileData(String directoryLocation, String fileName)

Description

read File Data

License

Open Source License

Declaration

@SuppressWarnings("resource")
    public static List<String> readFileData(String directoryLocation, String fileName) 

Method Source Code

//package com.java2s;
/**/*from  w w  w  . j  ava2 s.co m*/
 * Copyright (c) {2011} {meter@rbtsb.com} {
 * individual contributors as indicated by the @authors tag}.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Private License v1.0
 * which accompanies this distribution, and is available at
 * http://www.rbtsb.com
 */

import java.io.BufferedReader;

import java.io.DataInputStream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.ArrayList;

import java.util.List;

public class Main {
    @SuppressWarnings("resource")
    public static List<String> readFileData(String directoryLocation, String fileName) {
        FileInputStream fstream = null;
        List<String> contents = null;
        try {
            fstream = new FileInputStream(directoryLocation.concat(fileName));

            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;
            contents = new ArrayList<String>();
            try {
                while ((strLine = br.readLine()) != null) {
                    contents.add(strLine);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return contents;
    }
}

Related

  1. readFileAsJson(String path)
  2. readFileAsList(String path)
  3. readFileByCharAsString(String path, String encode)
  4. readFileCharacters(File file, boolean fix)
  5. readFileData(File file)
  6. readFileFromClassPath(String file)
  7. readFileFromDisk(String filepath)
  8. readFileFromResource(@SuppressWarnings("rawtypes") Class refClass, String filePath)
  9. readFileFromResource(String filename)