title: How to retrieve value from arraylist according to time interval?
body: <p>Hi I am trying to fetch a URL and when I fetch that URL I get a string. The string I kept in my <code>arraylist</code>. Now I want to print <code>arraylist</code> value. The condition is that only 15 values should print every x seconds.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class CommoditywiseGetUrl {
  
      public static void main(String args[]) {
          URL url;
          try {
              // get URL content
  
              String a = "http://122.160.81.37:8080/mandic/commoditywise?c=paddy";
              url = new URL(a);
              URLConnection conn = url.openConnection();
  
              // open the stream and put it into BufferedReader
              BufferedReader br = new BufferedReader(
                      new InputStreamReader(conn.getInputStream()));
              StringBuffer sb = new StringBuffer();
              String inputLine;
              ArrayList&lt;String&gt; list1 = new ArrayList&lt;String&gt;();
              ArrayList&lt;String&gt; list2 = new ArrayList&lt;String&gt;();
  
              while ((inputLine = br.readLine()) != null) {
  
                  String s = inputLine.replace("|", "\n");
  
                  s = s.replace("~", " ");
                  //System.out.println(s);
                  StringTokenizer str = new StringTokenizer(s);
                  while (str.hasMoreTokens()) {
                      String mandi = str.nextElement().toString();
  
                      String price = str.nextElement().toString();
  
  
                      list1.add(mandi);
                      list2.add(price);
                  }
              }
              String item1 = null;
              for (int i = 0; i &lt; list1.size(); i++) {
                  item1 = list1.get(i);
                  System.out.println("mandi" + item1);
              }
              for (int i = 0; i &lt; list2.size(); i++) {
                  String item2 = list2.get(i);
                  System.out.println("Price" + item2);
              }
  
              br.close();
  
              //System.out.println(sb);
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
  }
  </code></pre>
  
  <p>How can I reach my desired output?</p>
  
  <p>Thanks.</p>