title: How can I read comma separated values from a text file in Java?
body: <p>I have got this text file with latitude and longitude values of different points on a map.</p>
  
  <p>How can I split my string into latitudes and longitudes? What is the general way to do these type of things that is with other delimiters like space or tab etc.?
  Sample file:</p>
  
  <pre><code>28.515046280572285,77.38258838653564
  28.51430151808072,77.38336086273193
  28.513566177802456,77.38413333892822
  28.512830832397192,77.38490581512451
  28.51208605426073,77.3856782913208
  28.511341270865113,77.38645076751709
  </code></pre>
  
  <p>This is the code I am using to read from the file:</p>
  
  <pre><code>try(BufferedReader in = new BufferedReader(new FileReader("C:\\test.txt"))) {
      String str;
      while ((str = in.readLine()) != null) {
          System.out.println(str);
      }
  }
  catch (IOException e) {
      System.out.println("File Read Error");
  }
  </code></pre>