Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/main/java/org/mcsoxford/rss/RSSStringDumpParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.mcsoxford.rss;

import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.IOException;

/*
* RSS feed to string parser.
*
* @author Joris van Winden
*/

public class RSSStringDumpParser {

public RSSStringDumpParser() {}

/*
* Parses input stream as a string. It is the responsibility of the caller to
* close the stream.
*
* @param feed RSS 2.0 feed input stream
* @return string representation of the feed
* @throws RSSFault when io goes wrong
*/
public String parse(InputStream feed) {

BufferedReader reader = new BufferedReader(new InputStreamReader(feed));

StringBuilder result = new StringBuilder();

String line;

try {
while((line = reader.readLine()) != null) {
result.append(line);
}
} catch (IOException e) {
throw new RSSFault(e);
}

return result.toString();
}
}