badsha

Java stuff

Apr 2nd, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.awt.*;
  2. import java.util.*;
  3. import java.io.*;
  4. public class Interests {
  5.  
  6.     public static void main(String[] args) throws IOException
  7.     {
  8.         File inFile = new File("C:\\New Folder\\text1.txt");
  9.         Scanner inScan = new Scanner(inFile);
  10.  
  11.         ArrayList<String> array1 = new ArrayList<String>(400);
  12.  
  13.         while (inScan.hasNextLine()) array1.add(inScan.nextLine());
  14.  
  15.         inFile = new File("C:\\New Folder\\text2.txt");
  16.         inScan = new Scanner(inFile);
  17.  
  18.         while (inScan.hasNextLine()) array1.add(inScan.nextLine());
  19.  
  20.         Collections.sort(array1);
  21.        
  22.         Set<String> stringSet = new HashSet<String>();
  23.        
  24.         HashSet hs = new HashSet();
  25.         hs.addAll(array1);
  26.         array1.clear();
  27.         array1.addAll(hs);
  28.  
  29.         FileWriter fstream = new FileWriter("C:\\New Folder\\final.txt");
  30.         BufferedWriter out = new BufferedWriter(fstream);
  31.  
  32.         for (int a=0;a<array1.size();a++)
  33.         {
  34.             out.write(array1.get(a));out.write("\r\n");
  35.         }
  36.  
  37.         out.close();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment