X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneTextParser.java;h=18ac4678e66975074171ac3b0650da203715905a;hp=a1675d7178a8ba1c0acbbeab86291abb70f11923;hb=662bcd45433c0ab480ad0e52f3e72e9e886bdfc6;hpb=cb0161bb413434c393ae09d46001dba66b876875 diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index a1675d7..18ac467 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTextParser.java - Copyright © 2010–2013 David Roden + * Sone - SoneTextParser.java - Copyright © 2010–2015 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ import static java.util.logging.Logger.getLogger; import java.io.BufferedReader; import java.io.IOException; -import java.io.Reader; +import java.io.StringReader; import java.net.MalformedURLException; import java.util.logging.Level; import java.util.logging.Logger; @@ -118,9 +118,9 @@ public class SoneTextParser implements Parser { * {@inheritDoc} */ @Override - public Iterable parse(SoneTextParserContext context, Reader source) throws IOException { + public Iterable parse(SoneTextParserContext context, String source) throws IOException { PartContainer parts = new PartContainer(); - BufferedReader bufferedReader = (source instanceof BufferedReader) ? (BufferedReader) source : new BufferedReader(source); + BufferedReader bufferedReader = new BufferedReader(new StringReader(source)); try { String line; boolean lastLineEmpty = true; @@ -272,9 +272,7 @@ public class SoneTextParser implements Parser { lastLineEmpty = false; } } finally { - if (bufferedReader != source) { - Closer.close(bufferedReader); - } + Closer.close(bufferedReader); } for (int partIndex = parts.size() - 1; partIndex >= 0; --partIndex) { Part part = parts.getPart(partIndex);