Use HashMap:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
public class pring
{
private static ArrayList<String> data = new ArrayList<String>();
public static void main(String[] args) throws IOException
{
arrayListConstructor("C:/Users/DfroJaCk DB/Desktop/zongrecv.txt");
System.out.println(data);
}
public static void arrayListConstructor(String filename) throws IOException
{
HashMap<String, String> map = new HashMap<String, String>();
BufferedReader br = null;
br = new BufferedReader(new FileReader(filename));
String line = br.readLine();
while (line != null)
{
if (map.get(line) == null) {
System.out.println("new: " + line);
data.add(line);
map.put(line, line);
}
else
System.out.println("duplicate: " + line);
line = br.readLine();
}
br.close();
}
}