title: How to read and write the records in EhCache?
body: <p>Hi All,
          My current requirement is to store and read the records using EhCache. I am new to EhCache Implementation. I have read the EhCache Documentation and started to implement. I have done the records insert part and also read part. While the records are inserted, there will be *.data nd *.index files are created. Following is Code.</p>
  
  <pre><code>public class Driver
      {
      public static void main(String[] args) {
      CacheManager cm = CacheManager.create("ehcache.xml");
      Cache cache = cm.getCache("test");
      // I do a couple of puts
      for(int i=0;i&lt;10;i++){
          cache.put(new Element("key1", "val1"));
              cache.flush();
      }
      System.out.println(cache.getKeys());
      for(int i=0;i&lt;10;i++){
          Element el = cache.get("key"+i);
          System.out.println(el.getObjectValue());
      }
      cm.shutdown();  
      }
      }
  </code></pre>
  
  <p>Now what the issue is <strong>cm.shutdown()</strong>. If I am commenting this line and comment out the insert part and run the program means, Not able to retrieve the records and also *.index file is deleted. So In real scenario if the program is stopped abruptly means we can't read the records after startup. I want to know why the file is deleted and why I cant read the records in this situation... The Exception coming in the console is</p>
  
  <pre><code>net.sf.ehcache.util.SetAsList@b66cc
          Exception in thread "main" java.lang.NullPointerException
              at Driver.main(Driver.java:29)...
  </code></pre>
  
  <p>Any Input is needed Please..</p>