要设置的文件
/* *来 自 N o w J a v a . c o m - 时 代 Java */ //package com.nowjava; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.HashSet; import java.util.Set; public class Main { public static Set<String> fileToSet(File file, boolean toLowerCase, boolean trim) { try { Set<String> set = new HashSet<String>(); BufferedReader br = new BufferedReader(new FileReader(file)); String line = ""; while ((line = br.readLine()) != null) { if (toLowerCase)/**来 自 时 代 J a v a - N o w J a v a . c o m**/ set.add(line.toLowerCase()); else if (trim) set.add(line.trim()); else set.add(line); }