OPENJPA-2231 - introduce replace method using Reader for input stream.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1366475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Albert Lee 2012-07-27 18:12:44 +00:00
parent a7b90fd9ed
commit 8c2527215d
1 changed files with 5 additions and 0 deletions

View File

@ -43,6 +43,11 @@ public class TokenReplacedStream {
* input stream will be replaced by the (i+1)-th String in the output writer.
*/
public void replace(InputStream in, Writer out, String... prs) throws IOException {
BufferedReader inRdr = new BufferedReader(new InputStreamReader(in));
replace(inRdr, out, prs);
}
public void replace(Reader in, Writer out, String... prs) throws IOException {
if (prs.length%2 != 0)
throw new IllegalArgumentException("Even number of pattern/string pairs: " + Arrays.toString(prs)
+ ". Must be even number of arguments.");