title: how to repeat certain amount of code
body: <p>I have created an application that connect on a web-server and reads an xml file,there will be an update in the xml on the webserver  every 5 minutes.I want to connect on the webserver by using my application to get this updated xml file.How can i do that?
  this a sample code of my application</p>
  
  <pre><code> HandlingXMLStuff doingwork=new HandlingXMLStuff();
          try {
              URL website=new URL(FinalURL);
              SAXParserFactory spf=SAXParserFactory.newInstance();
              SAXParser sp=spf.newSAXParser();
              XMLReader xr=sp.getXMLReader();         
              xr.setContentHandler(doingwork);
              xr.parse(new InputSource(website.openStream()));
  
          } catch (MalformedURLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (ParserConfigurationException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (SAXException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  </code></pre>
  
  <p>and this the code of class that handle the xml file</p>
  
  <pre><code>public class HandlingXMLStuff extends DefaultHandler{
  
      String street1=null,street2=null,street3=null,street4=null;
  
      @Override
      public void startElement(String uri, String localName, String qName,
              Attributes attributes) throws SAXException {
          // TODO Auto-generated method stub
  
  
          if(localName.equals("Street1"))
          {
               street1=attributes.getValue("data");
  
          }
          if(localName.equals("Street2"))
          {
              street2=attributes.getValue("data");
  
          }
          if(localName.equals("Street3"))
          {
              street3=attributes.getValue("data");
  
          }
          if(localName.equals("Street4"))
          {
              street4=attributes.getValue("data");
  
          }
  
      }
  </code></pre>