Here you can find the source of readFile(String path)
public static Set<String> readFile(String path)
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.HashSet; import java.util.Set; public class Main { public static Set<String> readFile(String path) { Set<String> set = new HashSet<String>(); try {/*from w w w . ja v a 2s .c om*/ BufferedReader br = new BufferedReader(new FileReader(path)); String line = null; while ((line = br.readLine()) != null) { set.add(line.trim()); } br.close(); } catch (IOException e) { e.printStackTrace(); } return set; } }