Java BufferedReader Read readFileToListOfStrings(File file)

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

Description

read File To List Of Strings

License

Open Source License

Declaration

public static List<String> readFileToListOfStrings(File file) throws IOException 

Method Source Code


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

import java.io.*;

import java.util.*;

public class Main {
    public static List<String> readFileToListOfStrings(File file) throws IOException {
        List<String> strings = new LinkedList<>();
        BufferedReader reader = null;
        try {//w w w. ja  v  a 2s.c o m
            reader = new BufferedReader(new FileReader(file));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.replaceAll("\r", "").replaceAll("\n", "").replaceAll(" ", "");
                strings.add(line);
            }
            return strings;
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
    }
}

Related

  1. readFilePathToString(String filePath)
  2. readFileToHashMap(String filePath, String separator, boolean valueFirst)
  3. readFileToHashMap(String filePath, String separator, boolean valueFirst)
  4. readFileToList(String fileName, List list)
  5. readFileToList(String path, String split)
  6. readFileValue(File file)
  7. readFileWithoutLineBreak(String filename, boolean skipEmptyLine)