Example usage for org.apache.commons.lang3.text StrSubstitutor replaceIn

List of usage examples for org.apache.commons.lang3.text StrSubstitutor replaceIn

Introduction

In this page you can find the example usage for org.apache.commons.lang3.text StrSubstitutor replaceIn.

Prototype

public boolean replaceIn(final StrBuilder source) 

Source Link

Document

Replaces all the occurrences of variables within the given source builder with their matching values from the resolver.

Usage

From source file:org.xmlsh.modules.text.template.java

@Override
protected void processStream(Reader r, PrintWriter w) throws IOException {

    mLogger.entry(r, w);/*w  w  w .j a  v a  2 s.  c om*/
    StrSubstitutor sub = new StrSubstitutor(mVariables);
    StringBuilder sb = new StringBuilder();
    char cbuf[] = new char[1024];
    int len;
    while ((len = r.read(cbuf)) >= 0) {
        sb.append(cbuf, 0, len);
    }

    boolean result = sub.replaceIn(sb);

    w.write(sb.toString());
    w.flush();
    mLogger.exit();
}