title: Calling Two Different Methods into One Method in Java
body: <p>I wish to:</p>
  
  <ol>
  <li>Reading in two files</li>
  <li>Split the files into individual strings</li>
  <li>Compare the two string lists and retrieve strings that are unique to a file.</li>
  </ol>
  
  <p>At the moment I am running in to the problem of finding a way to call the two methods used to call in the files (one for each file) to the same method in order to be compared. </p>
  
  <p>Both methods use a try-catch-while statement and if I try to read all of the entries after the while statement only a single is shown and not the entire list. </p>
  
  <p>Is there a way to send parts of both methods as parameter to a single new method?</p>
  
  <p>Here is the code for the program. I know that there are problems with the way that I am doing the program, but I am only doing it the way that I was taught.</p>
  
  <pre><code>  File mainEmails = new File("Testrun.txt");
    Scanner inputScanner = null;
  
  
      int counter = 1;
      String fullName = null;
      String position = null;
      String companyName = null;
      String telNumber = null;
      String emailAddress = null;
  
    try
    {
  
      inputScanner = new Scanner(mainEmails);
  
    }
  
    catch(FileNotFoundException e)
    {
      System.out.println("File has not been found.");
    }
  
    while (inputScanner.hasNextLine())
    {
  
      String nextLine = inputScanner.nextLine();
      String [] splitFile = nextLine.split(",");
      for (int i = 0; i &lt;splitFile.length;i++)
      {
        if(i==0)
          {
            fullName = splitFile[0];
          }
          else if(i==1)
          {
            position = splitFile[1];
          }
          else if(i==2)
          {
            companyName = splitFile[2];
          }
          else if(i==3)
          {
            telNumber = splitFile[3];
          }
          else if(i==4)
          {
            emailAddress = splitFile[4];
          }
          else if(splitFile[i] == null)
        {
          System.out.println("You have failed!");
        }
      }
    }
  
  
  public static void deletionList()
  {
  
    File deletionEmails = new File("Testrun1.txt");
    Scanner inputScanner1 = null;
  
      String deletionfullName = null;
      String deletionposition = null;
      String deletioncompanyName= null;
      String deletiontelNumber = null;
      String deletionemailAddress = null;
  
      try
    {
      inputScanner1 = new Scanner(deletionEmails);
    }
      catch(FileNotFoundException e)
    {
      System.out.println("File has not been found.");
    }
     while (inputScanner1.hasNextLine())
    {
      String deletionnextLine = inputScanner1.nextLine();
      String [] deletionsplitFile = deletionnextLine.split(",");
      for (int i = 0; i &lt;deletionsplitFile.length;i++)
      {
        if(i==0)
          {
            deletionfullName = deletionsplitFile[0];
          }
          else if(i==1)
          {
            deletionposition = deletionsplitFile[1];
          }
          else if(i==2)
          {
            deletioncompanyName = deletionsplitFile[2];
          }
          else if(i==3)
          {
            deletiontelNumber = deletionsplitFile[3];
          }
          else if(i==4)
          {
            deletionemailAddress = deletionsplitFile[4];
          }
          else if(deletionsplitFile[i] == null)
        {
          System.out.println("You have failed!");
        }
      }
     }
  }
  </code></pre>
  
  <p>What I am trying to do is to take the fullName, emailAddress from the first split and deletionfullName and deletionemailAddress from the second split and compare the first and second of each, respectively. Each file will have a number of fields in it, and I am only interested in the fullName and emailAddress fields.</p>