Skip to content
Permalink
3b99e145f5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
35 lines (30 sloc) 984 Bytes
package utils;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
public class FileUtils {
public static Set<String> readFileAsSet(String filePath, boolean toLowerCase, boolean trim) {
String temp = "";
HashSet<String> lines = new HashSet<String>();
try {
BufferedReader in = new BufferedReader(new FileReader(filePath));
while ((temp = in.readLine()) != null) {
if (temp.length() > 0) {
String UTF8Str = new String(temp.getBytes(), "UTF-8");
if (trim)
UTF8Str = UTF8Str.trim();
lines.add(toLowerCase ? UTF8Str.toLowerCase() : UTF8Str);
}
}
in.close();
} catch (FileNotFoundException e) {
System.out.println("File not found, in reading file as list: " + e.getMessage());
} catch (IOException e) {
System.out.println("IOException in reading file as list: " + e.getMessage());
}
return lines;
}
}