Advertisement
andersfriis91

halpplz

Dec 18th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1.     public void load()
  2.     {
  3.         Scanner scan1 = null;
  4.         Scanner scan2 = null;
  5.     ArrayList MD51 = new ArrayList();
  6.     ArrayList MD52 = new ArrayList();
  7.        
  8.         try
  9.         {
  10.             scan1 = new Scanner(new FileReader(input1));
  11.             scan2 = new Scanner(new FileReader(input2));
  12.         }
  13.         catch (FileNotFoundException ex)
  14.         {
  15.             ex.printStackTrace();
  16.         }
  17.        
  18.         while (scan1.hasNextLine())
  19.         {
  20.             scan1.useDelimiter("\n");
  21.             String text = scan1.nextLine();
  22.             Scanner scanner = new Scanner(text);
  23.  
  24.             while (scanner.hasNext())
  25.             {
  26.                 scanner.next();            
  27.                 MD51.add(text);
  28.             }
  29.         }
  30.        
  31.         while (scan2.hasNextLine())
  32.         {
  33.             scan2.useDelimiter("\n");
  34.             String text = scan2.nextLine();
  35.            
  36.             Scanner scanner = new Scanner(text);
  37.             while (scanner.hasNext())
  38.             {
  39.                 scanner.next();
  40.                 MD52.add(text);
  41.             }
  42.         }
  43.     }
  44.     public int findDoubles()
  45.     {
  46.         int MD51Count = 0;
  47.         int MD52Count = 0;
  48.     int count;
  49.        
  50.         Object current1 =  MD51.get(MD51Count);
  51.         Object current2 =  MD52.get(MD52Count);
  52.        
  53.         while (current1 != null && current2 != null)
  54.         {
  55.             if (current1 == current2)
  56.             {
  57.                 count++;
  58.                 MD51Count++;
  59.                 MD52Count++;
  60.             }
  61.             else
  62.             {
  63.                 MD51Count++;
  64.                 MD52Count++;
  65.             }
  66.         }
  67.        
  68.         return count;
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement