title: How can return part of a string between two comma characters?
body: <p>say I'm given a set of strings that looks like this: </p>
  
  <pre><code>0,test0,dummy
  1,test,dummy
  2,test1,dummy
  3,test2,dummy
  4,test3,dum,dum,dummy
  </code></pre>
  
  <p>I wrote code that can return only what's before the last ",":</p>
  
  <pre><code>public class RandomTest {
  public static void main(String[] args) {
      String testFile = "synsets11.txt";
      In testIn = new In(testFile);
      while (testIn.hasNextLine()) {
          String line = testIn.readLine();
          String result = line.substring(0, line.lastIndexOf(","));
          List&lt;String&gt; synList = Arrays.asList(result.split(","));
          for (String i : synList) {
              System.out.println(i);
          }
      }
  }
  }
  </code></pre>
  
  <p>What I intended to do was only return the part of the string that was between the first and second "," characters, so my code above doesn't work for the last line of text. How do I only return what's between the first and second comma?
  In this case, only test0, test, test1, test2, and test3.</p>
  
  <p>thanks!</p>