Use XmlStreamReader in TypeGetter, closes #23
This commit is contained in:
parent
7ea73f01ae
commit
d34746e049
|
@ -1,9 +1,7 @@
|
|||
package de.danoeh.antennapod.syndication.handler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
@ -28,12 +26,11 @@ public class FeedHandler {
|
|||
factory.setNamespaceAware(true);
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
File file = new File(feed.getFile_url());
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
Reader inputStreamReader = new XmlStreamReader(file);
|
||||
InputSource inputSource = new InputSource(inputStreamReader);
|
||||
|
||||
saxParser.parse(inputSource, handler);
|
||||
inputStream.close();
|
||||
inputStreamReader.close();
|
||||
return handler.state.feed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import org.apache.commons.io.input.XmlStreamReader;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
@ -72,12 +73,15 @@ public class TypeGetter {
|
|||
}
|
||||
|
||||
private Reader createReader(Feed feed) {
|
||||
FileReader reader;
|
||||
Reader reader;
|
||||
try {
|
||||
reader = new FileReader(new File(feed.getFile_url()));
|
||||
reader = new XmlStreamReader(new File(feed.getFile_url()));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class FeedHandlerTest extends AndroidTestCase {
|
|||
private static final String FEEDS_DIR = "testfeeds";
|
||||
|
||||
private static final String[] urls = {
|
||||
"http://podcast.homerj.de/podcasts.xml",
|
||||
"http://www.dradio.de/rss/podcast/sendungen/wissenschaftundbildung/",
|
||||
"http://www.dradio.de/rss/podcast/sendungen/wirtschaftundverbraucher/",
|
||||
"http://www.dradio.de/rss/podcast/sendungen/literatur/",
|
||||
|
|
Loading…
Reference in New Issue