Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.util.*;
- import java.io.*;
- public class Interests {
- public static void main(String[] args) throws IOException
- {
- File inFile = new File("C:\\New Folder\\text1.txt");
- Scanner inScan = new Scanner(inFile);
- ArrayList<String> array1 = new ArrayList<String>(400);
- while (inScan.hasNextLine()) array1.add(inScan.nextLine());
- inFile = new File("C:\\New Folder\\text2.txt");
- inScan = new Scanner(inFile);
- while (inScan.hasNextLine()) array1.add(inScan.nextLine());
- Collections.sort(array1);
- Set<String> stringSet = new HashSet<String>();
- HashSet hs = new HashSet();
- hs.addAll(array1);
- array1.clear();
- array1.addAll(hs);
- FileWriter fstream = new FileWriter("C:\\New Folder\\final.txt");
- BufferedWriter out = new BufferedWriter(fstream);
- for (int a=0;a<array1.size();a++)
- {
- out.write(array1.get(a));out.write("\r\n");
- }
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment