title: Which design pattern to use to process different files in java?
body: <p>I have simple task to read the information from different files <strong>xml, rdf, txt</strong> with different structure and put it in some <strong>POJO</strong> custom object(MyObject). SO I am wondering which design pattern to use to make my code with better design.</p>
  
  <p>I think on the problem and I think I need <em><a href="http://www.tutorialspoint.com/design_pattern/factory_pattern.htm" rel="nofollow">Factory Patter</a></em> and the <em><a href="http://www.tutorialspoint.com/design_pattern/iterator_pattern.htm" rel="nofollow">Iterator Pattern</a></em>.
  On the factory to pass the file:</p>
  
  <pre><code>ReaderFactory factory = new ReaderFactory("input.rdf");
  //ReaderFactory factory = new ReaderFactory("input.xml");
  Iterator&lt;MyObject&gt; iter = factory.getIterator();
  </code></pre>
  
  <p>So the factory base on the file extension to choose which implemnetation of the iterator to return - these which reads rdf,xml or txt. Then with this iterator I easily can process the objects. Add add new files extensions reading in the future.</p>