Java BufferedReader Read loadList(String listName)

Here you can find the source of loadList(String listName)

Description

load List

License

Open Source License

Declaration

public static Set<String> loadList(String listName)
            throws FileNotFoundException, IOException 

Method Source Code

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

import java.io.BufferedReader;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static Set<String> loadList(String listName)
            throws FileNotFoundException, IOException {
        Set<String> list = new HashSet<String>();

        File file = new File(listName);
        if (file.exists()) {
            try (BufferedReader br = new BufferedReader(
                    new FileReader(file))) {
                for (String line; (line = br.readLine()) != null;)
                    list.add(line.trim().toLowerCase());
            }//  w  w  w .j  a v a  2 s. com
        }

        return list;
    }
}

Related

  1. loadLines(InputStream in, List lines)
  2. loadLines(String file)
  3. loadLines(String fileName)
  4. loadList(File f, String enc)
  5. loadList(final File file)
  6. loadListFromTextFile(String filename, String defaultitem, String linePrefix, String lineSuffix)
  7. loadLongArray(BufferedReader in)
  8. loadMetadata(File file)
  9. loadMetaFile(File metaFile)