Java BufferedReader Read loadList(final File file)

Here you can find the source of loadList(final File file)

Description

load List

License

Open Source License

Declaration

public static HashSet<String> loadList(final File file) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.io.BufferedReader;

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.HashSet;

public class Main {
    public static HashSet<String> loadList(final File file) {
        final HashSet<String> set = new HashSet<String>();
        BufferedReader br = null;
        try {/*from   www .  ja v a2  s  .co  m*/
            br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String line;
            while ((line = br.readLine()) != null) {
                line = line.trim();
                if (line.length() > 0 && line.charAt(0) != '#') {
                    set.add(line.trim().toLowerCase());
                }
            }
            br.close();
        } catch (final IOException e) {
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (final Exception e) {
                }
            }
        }
        return set;
    }
}

Related

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