In fact, you do not need a map. Here is an example that uses instead HashSet. (Assuming you want duplicate lines to be "muted".
String[] strs = "aa,bb,cc,aa,xx,cc,dd".split(",");
Set<String> seen = new HashSet<String>();
for (int i = 0; i < strs.length; i++)
if (!seen.add(strs[i]))
strs[i] = null;
System.out.println(Arrays.toString(strs));
source
share