Certamente grazie al fondamentale aiuto di un ragazzo:
import java.io.;
import java.util.;
public class Main {
public static void main(String[] args) throws Exception{ HashMap hm = new HashMap(); FileReader fr = new FileReader("NomeFile.txt"); BufferedReader br = new BufferedReader(fr); String s; while((s = br.readLine()) != null) { if (!hm.containsKey(s)) hm.put(s,s); } fr.close(); Set set = hm.entrySet(); Iterator i = set.iterator(); FileWriter fw = new FileWriter(new File("output.txt")); BufferedWriter bw = new BufferedWriter(fw); while(i.hasNext()){ Map.Entry me = (Map.Entry)i.next(); bw.write((String)me.getValue()); bw.newLine(); } fw.close(); }}