diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-09-24 14:08:26 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-09-24 14:08:26 +0200 |
commit | 08e4408717b15eb65f34fd85700ad396c8f02b1b (patch) | |
tree | 2a89506680d3026b8da36ab09e6057910e7fc79c /src | |
parent | 7b4aa15f85c3cb689c0c0f3af9e2aedf17324457 (diff) | |
download | AntennaPod-08e4408717b15eb65f34fd85700ad396c8f02b1b.zip |
Use XmlStreamReader to support different encodings
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/syndication/handler/FeedHandler.java | 12 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/syndication/handler/SyndHandler.java | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/syndication/handler/FeedHandler.java b/src/de/danoeh/antennapod/syndication/handler/FeedHandler.java index dfcfcf98d..050daf862 100644 --- a/src/de/danoeh/antennapod/syndication/handler/FeedHandler.java +++ b/src/de/danoeh/antennapod/syndication/handler/FeedHandler.java @@ -1,12 +1,17 @@ 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; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.apache.commons.io.input.XmlStreamReader; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; import de.danoeh.antennapod.feed.Feed; @@ -22,8 +27,13 @@ public class FeedHandler { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); SAXParser saxParser = factory.newSAXParser(); - saxParser.parse(new File(feed.getFile_url()), handler); + 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(); return handler.state.feed; } } diff --git a/src/de/danoeh/antennapod/syndication/handler/SyndHandler.java b/src/de/danoeh/antennapod/syndication/handler/SyndHandler.java index 31ab0c114..ff7942cdb 100644 --- a/src/de/danoeh/antennapod/syndication/handler/SyndHandler.java +++ b/src/de/danoeh/antennapod/syndication/handler/SyndHandler.java @@ -47,8 +47,7 @@ public class SyndHandler extends DefaultHandler { if (!state.tagstack.empty()) { if (state.getTagstack().size() >= 2) { if (state.contentBuf != null) { - String content = new String(ch, start, length); - state.contentBuf.append(content); + state.contentBuf.append(ch, start, length); } } } |