title: How to run read() function only once Spring Batch
body: <p>I am creating a Spring Batch job with folowing xml:   </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;batch:job id="simulatorJob" restartable="false"&gt;
      &lt;batch:step id="step1"&gt;
          &lt;batch:tasklet transaction-manager="transactionManager"&gt;
              &lt;batch:chunk reader="stockListner" writer="customWriter"
                  commit-interval="5"&gt;
              &lt;/batch:chunk&gt;
          &lt;/batch:tasklet&gt;
      &lt;/batch:step&gt;
  &lt;/batch:job&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /&gt;
  
  &lt;bean id="stockListner" class="com.XXX.stock.java.StockReader" scope="step"&gt;
      &lt;property name="URL" value="NTPC,TCS" /&gt;
      &lt;!-- &lt;property name="URL" value="NTPC" /&gt; --&gt;
      &lt;!-- &lt;property name="URL" value="TCS" /&gt; --&gt;
  &lt;/bean&gt;
  
  &lt;bean id="customWriter" class="com.XXX.stock.java.FlatFileWriter" /&gt;
  </code></pre>
  
  <p>This is my reader class:  </p>
  
  <pre><code>private String URL;
  
  public String getURL() {
      return URL;
  }
  
  public void setURL(String uRL) {
      URL = uRL;
  }
  
  public ArrayList&lt;StockData&gt; read() throws Exception, UnexpectedInputException,ParseException, NonTransientResourceException {
      ArrayList&lt;StockData&gt; list = new ArrayList&lt;StockData&gt;();
      String[] splitStocks = URL.split(",");      
  
      for(int i=0; i &lt; splitStocks.length;i++){
          list.add(stockReader.getStockData(splitStocks[i]));     
      }
      return list;        
  }  
  </code></pre>
  
  <p>But the reader class keeps on running. How do I stop at first run?   </p>
  
  <p>I tried this aswell:   </p>
  
  <pre><code>public StockData read() throws Exception, UnexpectedInputException,ParseException, NonTransientResourceException {
      ArrayList&lt;StockData&gt; list = new ArrayList&lt;StockData&gt;();
      String[] splitStocks = URL.split(",");
  
      for(int i=0; i &lt; splitStocks.length;i++)
      {  
             return stockReader.getStockData(splitStocks[i]);
      }
  
      return null;
  }  
  </code></pre>
  
  <p>The read() function goes into loop..</p>