title: How to search a CSV file based on an input field?
body: <p>I am able to access only few number of lines (41 lines to be proper).after that I am unable to read.</p>
  
  <pre><code>import java.io.File;
  import java.util.Scanner;
  
  public class FileReader {
  
      public static void main(String[] args) {
  
          String filePath = "qwe.csv";
          System.out.println("Enter the City name to be Searched\n");
  
          Scanner in = new Scanner(System.in);          
          String searchTerm = in.nextLine(); 
          readRecord(filePath, searchTerm);
      }
  
      public static void readRecord( String filePath, String searchTerm ) {
  
          boolean found = false;
          String City = ""; String City_Asciis = ""; String  Lattitude = "";
          String longitude = ""; String Country = "";
          String iso_2 = ""; String iso_3 = ""; String Admin_Name = "";
          String Capital = ""; String Population = ""; String Id = "";
  
          try {
              File file = new File(filePath);
              Scanner x = new Scanner (file);
              x.useDelimiter("[,\n]"); //to separate the data items 
  
              //hasNext - Returns true if the scanner has another token/value in its input
  
              while(x.hasNext() &amp;&amp; !found) {
  
                  City = x.next();
                  City_Asciis = x.next();
                  Lattitude = x.next();
                  longitude = x.next();
                  Country = x.next();
                  iso_2 = x.next();
                  iso_3 = x.next();
                  Admin_Name = x.next();
                  Capital = x.next();
                  Population = x.next();
                  Id = x.next();
  
                  if (City.equals(searchTerm)) {
                      found = true;
                  }
              }       
  
              if (found) {
  
                  System.out.println(" The following details are of city : " + City +"\n The Ascii string would be : "
                      + City_Asciis +"\n Its having the lattitude around : "
                      + Lattitude + "\n and Longitude of : "+ longitude +"\n It is situated in : "
                      + Country +"\n These have iso code like  : "+ iso_2 +" and : "+ iso_3 +"\n It comes under  : "
                      + Admin_Name +" State \n Capital of this city is : "+ Capital +"\n The population is around : "
                      + Population +"\n ZIP code is : "+Id+"");
              }                       
              else {                      
                  System.out.print("Enter the Correct City Name");
              }
          }
          catch(Exception e1){
              System.out.print("file not found \n");
              e1.printStackTrace();
          }  
      }       
  }
  </code></pre>
  
  <p>This code will load the searched city from the file path given, so that given a particular city name print the details of the city.</p>