title: String array name search
body: <p>So I have a file which has all presidents in it - their first name, middle initial (if any), and last name.</p>
  
  <p>The file needs to be read in, and a user can enter a president's name to search for it, and that president should be displayed.</p>
  
  <p>I have it displaying the president if a user searches by first name or by last name, but not by both.</p>
  
  <p>For example, the external file contains:</p>
  
  <pre><code>George,Washington,(1789-1797)
  Franklin,D.,Roosevelt,(1933-1945)
  ... and so on with all the presidents
  </code></pre>
  
  <p>I need the user to be able to either type in the first name, the last name, or both first and last name and get the desired result (the date is irrelevant for the most part).</p>
  
  <p>Tried lots of different things, but not getting there as far as displaying the president if user searches by first and last name.</p>
  
  <p>Here is what I got so far:</p>
  
  <pre><code>public class NameSearch {
  
      public static void main(String[] args) throws IOException {
  
          try {
              // read from presidents file
              Scanner presidentsFile = new Scanner(new File("Presidents.txt"));
              // scanner for user input
              Scanner keyboard = new Scanner(System.in);
              // create array list of each line in presidents file
              ArrayList&lt;String&gt; presidentsArrayList = new ArrayList&lt;String&gt;();
  
              // prompt user to enter a string to see if it matches with a president's name
              System.out.println("Enter a search string of letters to find a president match: ");
              // store user input
              String userInput = keyboard.nextLine();
  
              // add president file info to array list linesInPresidentFile
              while (presidentsFile.hasNextLine()) {
                  presidentsArrayList.add(presidentsFile.nextLine());
              } // end while loop
  
              String presidentNamesArray[] = presidentsArrayList.toArray(new String[presidentsArrayList.size()]);
              String results = searchArray(presidentNamesArray, userInput);
  
              //System.out.println("\nThe presidents who have \"" + userInput + "\" as part of their name are: ");
  
          } catch (FileNotFoundException ex) {
              // print out error (if any) to screen
              System.out.println(ex.toString());
  
          } // end catch block
  
      } // end main
  
      // method to search for a specific value in an array
      public static String searchArray(String array[], String value) {
  
          for (int i = 0; i &lt; array.length; i++) {
              if (array[i].toLowerCase().contains(value.toLowerCase())) {
                  String splitter[] = array[i].split(" ,");
                  System.out.println(Arrays.toString(splitter));
              }
  
          }
          return Arrays.toString(array);
      }
  
  }
  </code></pre>