Code example for URL

Methods: openStream

0
 
    @Override 
    public void convert(String src, String dest) throws Exception{
        new File(dest).delete();
 
        URL mXMLUrl = new URL("file:///" + src);
        cardList = new LinkedList<Card>();
        characterBuf = new StringBuffer();
 
        System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");
 
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();
        xr.setContentHandler(this);
        xr.parse(new InputSource(mXMLUrl.openStream()));
 
        AnyMemoDBOpenHelper helper = AnyMemoDBOpenHelperManager.getHelper(mContext, dest);
        try { 
            CardDao cardDao = helper.getCardDao();
            cardDao.createCards(cardList);