title: Split and Loop in java 8
body: <p>I have this problem which I want to solve in java 8,</p>
  
  <p>I have a string which is concatenated by <code>.</code> </p>
  
  <pre><code>A.B.C.D
  </code></pre>
  
  <p>Number of characters in the string can vary.</p>
  
  <p>I have this method, which takes the string as input and number of level deep it has to go,
  I have to loop through the number that i get after applying a split on string with "." and go just given level deep</p>
  
  <pre><code>private String getResponse (String str, int level) {
  // for now, simply print the entire string first and then start removing last alphabet of it one by one till the value of level
  // ex : str = A.B.C.D
  // System.out.println("Doing a call with key as = " + str); =&gt; should give me A.B.C.D
  // Apply logic of split 
  // System.out.println("Doing a call with key as = " + str); =&gt; should give me A.B.C
  // Split again
  // System.out.println("Doing a call with key as = " + str); =&gt; should give me A.B
  // this should go in loop till we reach the level
  }
  </code></pre>
  
  <p>Can this be done in java 8?</p>